quwangxin 3 лет назад
Родитель
Сommit
3ab24f0a17

+ 1 - 0
src/components/CommomSelect/dept-select.vue

@@ -10,6 +10,7 @@
     default-expand-all
     :placeholder="placeholder"
     @input="updateValue"
+    v-on="$listeners"
   />
 </template>
 

+ 1 - 0
src/components/CommomSelect/equipment-select.vue

@@ -10,6 +10,7 @@
     default-expand-all
     :placeholder="placeholder"
     @input="updateValue"
+    v-on="$listeners"
   />
 </template>
 

+ 653 - 617
src/components/addPatrolPlanDialog/index.vue

@@ -15,7 +15,7 @@
         label-width="120px"
       >
         <el-row>
-<!--          <el-col :span="8">
+          <!--          <el-col :span="8">
             <el-form-item label="计划单号" prop="planCode">
               <el-input
                 v-model="addForm.planCode"
@@ -79,7 +79,7 @@
           </el-col>
           <el-col :span="8">
             <el-form-item label="设备分类" prop="bizTypeId">
-              <el-select
+              <!-- <el-select
                 v-model="addForm.bizTypeId"
                 size="small"
                 style="width: 100%"
@@ -91,7 +91,11 @@
                   :label="item.name"
                   @click.native="handleEquipmentClassChange(item)"
                 ></el-option>
-              </el-select>
+              </el-select> -->
+              <equipmentSelect
+                v-model="addForm.bizTypeId"
+                @change="handleEquipmentClassChange"
+              />
             </el-form-item>
           </el-col>
           <el-col :span="8">
@@ -134,9 +138,13 @@
             </el-form-item>
           </el-col>
           <el-col :span="8" v-if="addForm.isSyncBill">
-            <el-form-item :label="formLabel + '人员'" prop="executorId"
-			  :rules="[{required: true, message: '请选择'+formLabel + '人员'}] "
-			>
+            <el-form-item
+              :label="formLabel + '人员'"
+              prop="executorId"
+              :rules="[
+                { required: true, message: '请选择' + formLabel + '人员' }
+              ]"
+            >
               <el-select
                 v-model="addForm.executorId"
                 size="small"
@@ -149,8 +157,8 @@
                   :label="item.trueName"
                   @click.native="
                     {
-                      addForm.executorName = item.trueName
-                      addForm.executorPhone = item.mobile
+                      addForm.executorName = item.trueName;
+                      addForm.executorPhone = item.mobile;
                     }
                   "
                 ></el-option>
@@ -212,7 +220,10 @@
               >添加操作事项</el-button
             >
             <el-table
-              :data="addForm.planEquiList[currentEquItemIndex]&&addForm.planEquiList[currentEquItemIndex].itemList"
+              :data="
+                addForm.planEquiList[currentEquItemIndex] &&
+                addForm.planEquiList[currentEquItemIndex].itemList
+              "
               border
             >
               <el-table-column label="序号" align="center" width="60">
@@ -244,9 +255,12 @@
               >添加备品备件</el-button
             >
             <el-table
-              :data="addForm.planEquiList[currentEquItemIndex]&&addForm.planEquiList[currentEquItemIndex].partList"
+              :data="
+                addForm.planEquiList[currentEquItemIndex] &&
+                addForm.planEquiList[currentEquItemIndex].partList
+              "
               height="300"
-              :key='currentEquItemIndex'
+              :key="currentEquItemIndex"
               border
             >
               <el-table-column label="序号" align="center" width="60">
@@ -254,7 +268,11 @@
                   <span>{{ scope.$index + 1 }}</span>
                 </template>
               </el-table-column>
-              <el-table-column label="备件名称" align="center" prop="informationName">
+              <el-table-column
+                label="备件名称"
+                align="center"
+                prop="informationName"
+              >
               </el-table-column>
               <el-table-column label="规格型号" align="center" prop="modelType">
               </el-table-column>
@@ -273,9 +291,10 @@
               <el-table-column label="单位" align="center" prop="measuringUnit">
               </el-table-column>
               <el-table-column label="费用" align="center" prop="univalence">
-                  <template slot-scope="scope">
-                     {{scope.row.num*scope.row.univalence}}{{scope.row.univalenceUnit=='wanyuan'?'万元':'元'}}
-                  </template>
+                <template slot-scope="scope">
+                  {{ scope.row.num * scope.row.univalence
+                  }}{{ scope.row.univalenceUnit == 'wanyuan' ? '万元' : '元' }}
+                </template>
               </el-table-column>
               <el-table-column label="操作" align="center" width="70">
                 <template slot-scope="scope">
@@ -287,8 +306,14 @@
                 </template>
               </el-table-column>
             </el-table>
-            <div style="text-align: center">备件总费用:
-              {{addForm.planEquiList[currentEquItemIndex]&&addForm.planEquiList[currentEquItemIndex].totalCost?addForm.planEquiList[currentEquItemIndex].totalCost:'-'}}
+            <div style="text-align: center"
+              >备件总费用:
+              {{
+                addForm.planEquiList[currentEquItemIndex] &&
+                addForm.planEquiList[currentEquItemIndex].totalCost
+                  ? addForm.planEquiList[currentEquItemIndex].totalCost
+                  : '-'
+              }}
             </div>
           </div>
@@ -315,648 +340,659 @@
 </template>
 
 <script>
-// import planRules from '@/api/planRules/patrolConfig'
-// import { handleSave } from '@/api/stockManagement/stocking'
-// import contentConfig from '@/api/maintenance/patrol/ruleConfig'
-// import { getAssetsList } from '@/api/ledgerAssets/booksList'
-// import user from '@/api/main/user'
-// import dept from '@/api/main/dept'
-// import SelectTree from '@/components/selectTree'
-import RuleItemSelection from '@/components/ruleItemSelection'
-import AddSpareDialog from '@/components/addSpareDialog'
-// import { getRuleNo } from '@/utils'
-import { mapGetters } from 'vuex'
-// import { getRuleNameList } from '@/api/stockManagement/stocking'
-import {deepClone} from "@/utils"
-export default {
-  name: 'addPatrolPlanDialog',
-  components: { 
-		// SelectTree,
-		 RuleItemSelection, AddSpareDialog ,
-	},
-  props: {
-    dialogTitle: {
-      type: String,
-      default: () => {
-        return '新增巡点检计划'
+  import equipmentSelect from '@/components/CommomSelect/equipment-select.vue';
+  import RuleItemSelection from '@/components/ruleItemSelection';
+  import AddSpareDialog from '@/components/addSpareDialog';
+  import { getRule } from '@/api/ruleManagement/plan';
+  // import { getRuleNo } from '@/utils'
+  import { mapGetters } from 'vuex';
+  // import { getRuleNameList } from '@/api/stockManagement/stocking'
+  import { deepClone } from '@/utils';
+  export default {
+    name: 'addPatrolPlanDialog',
+    components: {
+      // SelectTree,
+      equipmentSelect,
+      RuleItemSelection,
+      AddSpareDialog
+    },
+    props: {
+      dialogTitle: {
+        type: String,
+        default: () => {
+          return '新增巡点检计划';
+        }
       }
-    }
-  },
-  data () {
-    return {
-      defaultProps: {
-        label: 'showName'
-      },
-      addPatrolPlanDialog: false,
-      matterRulesList: [], // 选择规则名称的时候,获取的事项
-      equipmentInfo: {},
-      clickedTreeNode: false,
-      selectedMatter: [],
-      selectedSpare: [],
-      uerList: [],
-      deptList: [],
-      executorList: [],
-      currentEquItemIndex: 0,
-      formLabel: '',
-      planRuleTypeObj: {
-        1: 'PATROL',
-        2: 'MAINTAIN',
-        4: 'INVENTORY'
-      },
-      addForm: {
-        assetDict: '1',
-        assetsName: '生产设备',
-        // planCode: getRuleNo('PL'), // 计划单号
-        cycleType: 2,
-        planName: '', // 计划名称
-        isSyncBill: true, // 自动派单
-        ruleId: '', // 规则id
-        ruleName: '', // 规则名称
-        duration: '', // 计划完成时长
-        bizTypeId: '', // 设备分类Id
-        bizTypeName: '', // 设备分类name
-        verifyUserId: '', // 审核人id
-        verifyUserName: '', // 审核人name
-        executorDeptCode: '', // 巡点检部门code
-        executorDeptName: '', // 巡点检部门name
-        executorId: '', // 巡点检人员id
-        executorName: '', // 巡点检人员name
-        executorPhone: '', // 巡点检人员电话
-        remark: '', // 备注
-        planType: 'PATROL', // 计划规则类型 巡点检: 'PATROL', 保养: 'MAINTAIN', 盘点: 'INVENTORY'
-        // 计划规则设备列表
-        planEquiList: [
-          {
-            equiCode: '', // 设备编码 equCode
-            equiName: '', // 设备名称 name
-            equiModel: '', // 设备型号 specifications
-            equiLocation: '', // 设备位置 positionFarm
-            // 设备事项
-            itemList: [
-              // {
-              //   name: '', // 事项名称
-              //   content: '', // 事项内容
-              //   norm: '' // 事项标准
-              // }
-            ],
-            // 设备备品备件 - 巡点检不需要备品备件,保养需要
-            partList: [
-              //   {
-              //     code: '', // 备品备件code
-              //     name: '', // 备品备件name
-              //     model: '', // 备品备件型号
-              //     num: '', // 所需数量
-              //     unit: '', // 单位
-              //     amount: '', // 费用
-              //   }
-            ],
-            totalCost:0,
+    },
+    data () {
+      return {
+        defaultProps: {
+          label: 'showName'
+        },
+        addPatrolPlanDialog: false,
+        matterRulesList: [], // 选择规则名称的时候,获取的事项
+        equipmentInfo: {},
+        clickedTreeNode: false,
+        selectedMatter: [],
+        selectedSpare: [],
+        uerList: [],
+        deptList: [],
+        executorList: [],
+        currentEquItemIndex: 0,
+        formLabel: '',
+        planRuleTypeObj: {
+          1: 'PATROL',
+          2: 'MAINTAIN',
+          4: 'INVENTORY'
+        },
+        addForm: {
+          assetDict: '1',
+          assetsName: '生产设备',
+          // planCode: getRuleNo('PL'), // 计划单号
+          cycleType: 2,
+          planName: '', // 计划名称
+          isSyncBill: true, // 自动派单
+          ruleId: '', // 规则id
+          ruleName: '', // 规则名称
+          duration: '', // 计划完成时长
+          bizTypeId: '', // 设备分类Id
+          bizTypeName: '', // 设备分类name
+          verifyUserId: '', // 审核人id
+          verifyUserName: '', // 审核人name
+          executorDeptCode: '', // 巡点检部门code
+          executorDeptName: '', // 巡点检部门name
+          executorId: '', // 巡点检人员id
+          executorName: '', // 巡点检人员name
+          executorPhone: '', // 巡点检人员电话
+          remark: '', // 备注
+          planType: 'PATROL', // 计划规则类型 巡点检: 'PATROL', 保养: 'MAINTAIN', 盘点: 'INVENTORY'
+          // 计划规则设备列表
+          planEquiList: [
+            {
+              equiCode: '', // 设备编码 equCode
+              equiName: '', // 设备名称 name
+              equiModel: '', // 设备型号 specifications
+              equiLocation: '', // 设备位置 positionFarm
+              // 设备事项
+              itemList: [
+                // {
+                //   name: '', // 事项名称
+                //   content: '', // 事项内容
+                //   norm: '' // 事项标准
+                // }
+              ],
+              // 设备备品备件 - 巡点检不需要备品备件,保养需要
+              partList: [
+                //   {
+                //     code: '', // 备品备件code
+                //     name: '', // 备品备件name
+                //     model: '', // 备品备件型号
+                //     num: '', // 所需数量
+                //     unit: '', // 单位
+                //     amount: '', // 费用
+                //   }
+              ],
+              totalCost: 0
+            }
+          ],
+          sparePartsApply: {
+            sourceType: 1,
+            status: 0,
+            sparePartsApplyDetailList: []
           }
-        ],
-        sparePartsApply:{
-          sourceType:1,
-          status:0,
-          sparePartsApplyDetailList:[]
-        }
-      },
-      addFormRules: {
-        planName: [
-          { required: true, message: '请输入计划配置名称' }
-        ],
-        isSyncBill: [
-          { required: true, message: '请选择是否自动派单' }
-        ],
-        ruleId: [
-          { required: true, message: '请选择规则名称' }
-        ],
-        duration: [
-          { required: true, message: '请输入计划完成时长' }
-        ],
-        bizTypeId: [
-          { required: true, message: '请选择设备分类' }
-        ],
-        verifyUserId: [
-          { required: false, message: '请选择审核人' }
-        ],
-        executorDeptCode: [
-          { required: true, message: '请选择选择巡点检部门'}
-        ],
-        // executorId: [
-        //   { required: true, message: '请选择选择保养人员'}
-        // ]
-      },
-      ruleNameList:[],
-      currentNode:null,
-
+        },
+        addFormRules: {
+          planName: [{ required: true, message: '请输入计划配置名称' }],
+          isSyncBill: [{ required: true, message: '请选择是否自动派单' }],
+          ruleId: [{ required: true, message: '请选择规则名称' }],
+          duration: [{ required: true, message: '请输入计划完成时长' }],
+          bizTypeId: [{ required: true, message: '请选择设备分类' }],
+          verifyUserId: [{ required: false, message: '请选择审核人' }],
+          executorDeptCode: [
+            { required: true, message: '请选择选择巡点检部门' }
+          ]
+          // executorId: [
+          //   { required: true, message: '请选择选择保养人员'}
+          // ]
+        },
+        ruleNameList: [],
+        currentNode: null
+      };
+    },
+    computed: {
+      ...mapGetters([
+        'equipmentList'
+        // 'ruleNameList'
+      ])
+    },
+    watch: {
+      addPatrolPlanDialog (val) {
+        if (val) {
+          this.formLabel = this.dialogTitle.includes('巡点检')
+            ? '巡点检'
+            : this.dialogTitle.includes('保养')
+            ? '保养'
+            : '盘点';
+          const planRuleTypeObj = {
+            巡点检: 'PATROL',
+            保养: 'MAINTAIN',
+            盘点: 'INVENTORY'
+          };
+          this.addForm.planType = planRuleTypeObj[this.formLabel];
 
-    }
-  },
-  computed: {
-    ...mapGetters([
-      'equipmentList',
-       // 'ruleNameList'
-    ])
-  },
-  watch: {
-    addPatrolPlanDialog (val) {
-      if (val) {
-        this.formLabel = this.dialogTitle.includes('巡点检')
-          ? '巡点检'
-          : this.dialogTitle.includes('保养')
-          ? '保养'
-          : '盘点'
-        const planRuleTypeObj = {
-          巡点检: 'PATROL',
-          保养: 'MAINTAIN',
-          盘点: 'INVENTORY'
+          // // 获取审核人列表数据
+          // this.getUserList();
+          // // 获取部门
+          // this.getDeptList();
+          // 获取规则名称
+          this._getRuleNameList();
         }
-        this.addForm.planType = planRuleTypeObj[this.formLabel]
-
-        // 获取审核人列表数据
-        this.getUserList()
-        // 获取部门
-        this.getDeptList()
-        // 获取规则名称
-        this._getRuleNameList()
       }
-    }
-  },
-  async created () {
-    // 获取设备分类下拉数据
-    await this.$store.dispatch('communal/setEquipmentList')
-  },
-  methods: {
-    // 获取规则名列表
-    async _getRuleNameList () {
-      if(this.dialogTitle=='新增巡点检计划'){
-        console.log('巡点检计划')
-        const res = await getRuleNameList({ruleTypeEm:'PATROL'})
-        if (res?.success) {
-          this.ruleNameList = res.data || []
+    },
+    async created () {
+      // 获取设备分类下拉数据
+      await this.$store.dispatch('communal/setEquipmentList');
+    },
+    methods: {
+      // 获取规则名列表
+      async _getRuleNameList () {
+        if (this.dialogTitle == '新增巡点检计划') {
+          console.log('巡点检计划');
+          const res = await getRule({ type: 1, pageNum: 1, size: -1 });
+          if (res?.success) {
+            this.ruleNameList = res.data || [];
+          }
         }
-      }
-      if(this.dialogTitle=='新增保养计划'){
-        console.log('保养计划')
-        const res = await getRuleNameList({ruleTypeEm:'MAINTAIN'})
-        if (res?.success) {
-          this.ruleNameList = res.data || []
+        if (this.dialogTitle == '新增保养计划') {
+          console.log('保养计划');
+          const res = await getRule({ type: 2, pageNum: 1, size: -1 });
+          if (res?.success) {
+            this.ruleNameList = res.data || [];
+          }
         }
-      }
-    },
-    handleClose () {
-      this.addPatrolPlanDialog = false
-      this.$refs.addFormRef.resetFields()
-      if (this.$refs.searchTree) {
-        this.$refs.searchTree.clearHandle()
-      }
-      this.currentEquItemIndex = 0
-      this.equipmentInfo = {}
-      this.addForm = {
-        assetDict: '1',
-        assetsName: '生产设备',
-        // planCode: getRuleNo('PL'), // 计划单号
-        cycleType: 2,
-        planName: '', // 计划名称
-        isSyncBill: true, // 自动派单
-        ruleId: '', // 规则id
-        duration: null, // 计划完成时长
-        bizTypeId: '', // 设备分类Id
-        bizTypeName: '', // 设备分类name
-        verifyUserId: '', // 审核人id
-        verifyUserName: '', // 审核人name
-        executorDeptCode: '', // 巡点检部门code
-        executorDeptName: '', // 巡点检部门name
-        executorId: '', // 巡点检人员id
-        executorName: '', // 巡点检人员name
-        executorPhone: '', // 巡点检人员电话
-        remark: '', // 备注
-        planType: 'PATROL', // 计划规则类型 巡点检: 'PATROL', 保养: 'MAINTAIN', 盘点: 'INVENTORY'
-        // 计划规则设备列表
-        planEquiList: [
-          {
-            equiCode: '', // 设备编码 equCode
-            equiName: '', // 设备名称 name
-            equiModel: '', // 设备型号 specifications
-            equiLocation: '', // 设备位置 positionFarm
-            // 设备事项
-            itemList: [
-              // {
-              //   name: '', // 事项名称
-              //   content: '', // 事项内容
-              //   norm: '' // 事项标准
-              // }
-            ],
-            // 设备备品备件 - 巡点检不需要备品备件,保养需要
-            partList: [
-              //   {
-              //     code: '', // 备品备件code
-              //     name: '', // 备品备件name
-              //     model: '', // 备品备件型号
-              //     num: '', // 所需数量
-              //     unit: '', // 单位
-              //     amount: '', // 费用
-              //   }
-            ],
-            totalCost:0
+      },
+      handleClose () {
+        this.addPatrolPlanDialog = false;
+        this.$refs.addFormRef.resetFields();
+        if (this.$refs.searchTree) {
+          this.$refs.searchTree.clearHandle();
+        }
+        this.currentEquItemIndex = 0;
+        this.equipmentInfo = {};
+        this.addForm = {
+          assetDict: '1',
+          assetsName: '生产设备',
+          // planCode: getRuleNo('PL'), // 计划单号
+          cycleType: 2,
+          planName: '', // 计划名称
+          isSyncBill: true, // 自动派单
+          ruleId: '', // 规则id
+          duration: null, // 计划完成时长
+          bizTypeId: '', // 设备分类Id
+          bizTypeName: '', // 设备分类name
+          verifyUserId: '', // 审核人id
+          verifyUserName: '', // 审核人name
+          executorDeptCode: '', // 巡点检部门code
+          executorDeptName: '', // 巡点检部门name
+          executorId: '', // 巡点检人员id
+          executorName: '', // 巡点检人员name
+          executorPhone: '', // 巡点检人员电话
+          remark: '', // 备注
+          planType: 'PATROL', // 计划规则类型 巡点检: 'PATROL', 保养: 'MAINTAIN', 盘点: 'INVENTORY'
+          // 计划规则设备列表
+          planEquiList: [
+            {
+              equiCode: '', // 设备编码 equCode
+              equiName: '', // 设备名称 name
+              equiModel: '', // 设备型号 specifications
+              equiLocation: '', // 设备位置 positionFarm
+              // 设备事项
+              itemList: [
+                // {
+                //   name: '', // 事项名称
+                //   content: '', // 事项内容
+                //   norm: '' // 事项标准
+                // }
+              ],
+              // 设备备品备件 - 巡点检不需要备品备件,保养需要
+              partList: [
+                //   {
+                //     code: '', // 备品备件code
+                //     name: '', // 备品备件name
+                //     model: '', // 备品备件型号
+                //     num: '', // 所需数量
+                //     unit: '', // 单位
+                //     amount: '', // 费用
+                //   }
+              ],
+              totalCost: 0
+            }
+          ],
+          sparePartsApply: {
+            sourceType: 1,
+            status: 0,
+            sparePartsApplyDetailList: []
           }
-        ],
-        sparePartsApply:{
-          sourceType:1,
-          status:0,
-          sparePartsApplyDetailList:[]
+        };
+      },
+      // 设备分类选择
+      async handleEquipmentClassChange (val) {
+        this.clickedTreeNode = true;
+        this.equipmentInfo = {};
+        this._getEquipmentList(val.id);
+      },
+      // 封装 - 获取设备分类列表
+      async _getEquipmentList (val) {
+        const params = { page: 1, size: 99999 };
+        const data = { classificationId: parseInt(val) };
+        try {
+          const res = await getAssetsList(params, data);
+          // console.log('设备列表:', res)
+          this.addForm.planEquiList = res.data.records;
+          this.addForm.planEquiList.map((item) => {
+            item.showName = item.name + '(' + item.code + ')';
+          });
+          this.currentEquItemIndex = 0;
+          this.currentNode = this.addForm.planEquiList[0];
+          const item = this.addForm.planEquiList[0];
+          // console.log(item)
+          const { equiLocation, equiLocationCode } = this.getEquiLocation(item);
+
+          this.$nextTick(() => {
+            this.$refs.planEquiList.setCurrentKey(item.id);
+            this.equipmentInfo = {
+              equiCode: item.code,
+              equiName: item.name,
+              equiId: item.id,
+              equiModel: item.specification,
+              // 设备位置 厂房(positionWorkshop)-车间(positionFarm)-产线(positionLine)-工位(positionFactory)
+              equiLocation,
+              equiLocationCode
+            };
+            this.currentEquItemIndex = 0;
+            this.addForm.planEquiList[0]['equiLocation'] = equiLocation;
+            this.addForm.planEquiList[0]['equiLocationCode'] = equiLocationCode;
+          });
+        } catch (error) {
+          this.addForm.planEquiList = [];
         }
-      }
-    },
-    // 设备分类选择
-    async handleEquipmentClassChange (val) {
-      this.clickedTreeNode = true
-      this.addForm.bizTypeName = val.name
-      this.equipmentInfo = {}
-      this._getEquipmentList(val.id)
-    },
-    // 封装 - 获取设备分类列表
-    async _getEquipmentList (val) {
-      const params = { page: 1, size: 99999 }
-      const data =  { classificationId: parseInt(val)  }
-      try {
-        const res = await getAssetsList(params, data)
-        // console.log('设备列表:', res)
-        this.addForm.planEquiList = res.data.records
-        this.addForm.planEquiList.map(item=>{
-            item.showName = item.name+'('+item.code+')'
-        })
-        this.currentEquItemIndex = 0
-        this.currentNode = this.addForm.planEquiList[0]
-        const item = this.addForm.planEquiList[0]
-        // console.log(item)
-        const { equiLocation, equiLocationCode } = this.getEquiLocation(item)
+      },
 
-        this.$nextTick(() => {
-          this.$refs.planEquiList.setCurrentKey(item.id)
-          this.equipmentInfo = {
-            equiCode: item.code,
-            equiName: item.name,
-            equiId: item.id,
-            equiModel: item.specification,
-            // 设备位置 厂房(positionWorkshop)-车间(positionFarm)-产线(positionLine)-工位(positionFactory)
-            equiLocation,
-            equiLocationCode
+      // 获取审核人列表、巡点检人员
+      async getUserList (params) {
+        try {
+          let data = { status: 1, page: 1, size: 999999 };
+          // 如果传了参数就是获取巡点检人员数据
+          if (params) {
+            data = Object.assign(data, params);
           }
-          this.currentEquItemIndex = 0
-          this.addForm.planEquiList[0]['equiLocation'] = equiLocation
-          this.addForm.planEquiList[0]['equiLocationCode'] = equiLocationCode
-        })
-      } catch (error) {
-        this.addForm.planEquiList = []
-      }
-    },
+          const res = await user.list(data);
+          if (params) {
+            this.executorList = res.data.items;
+          } else {
+            this.uerList = res.data.items;
+          }
+        } catch (error) {}
+      },
+      // 获取部门列表数据
+      async getDeptList () {
+        try {
+          let tree = await dept.tree();
+          this.deptList = tree.data;
+        } catch (error) {}
+      },
+      //选择部门(搜索)
+      searchDeptNodeClick (info) {
+        if (info) {
+          this.addForm.executorDeptCode = info.code;
+          this.addForm.executorDeptName = info.name;
+          // this.addForm.executorId = info.executorId
+          this.addForm.executorName = info.executorName;
+          this.addForm.executorPhone = info.executorPhone;
+          // 根据部门获取人员
+          const params = { deptCode: info.code, status: 1 };
+          this.getUserList(params);
+        } else {
+          this.addForm.executorDeptCode = null;
+        }
+      },
+      // 封装 - 获取设备位置名称和code方法
+      getEquiLocation (data) {
+        // 设备位置名称
+        const positionWorkshop = data.positionWorkshop
+          ? data.positionWorkshop + '-'
+          : '';
+        const positionFarm = data.positionFarm ? data.positionFarm + '-' : '';
+        const positionLine = data.positionLine ? data.positionLine + '-' : '';
+        const positiondetail = data.detailLocation ? data.detailLocation : '';
+        const equiLocation =
+          positionWorkshop + positionFarm + positionLine + positiondetail;
+        // 设备位置编码
+        const positionWorkshopCode = data.positionWorkshopCode
+          ? data.positionWorkshopCode + '-'
+          : '';
+        const positionFarmCode = data.positionFarmCode
+          ? data.positionFarmCode + '-'
+          : '';
+        const positionLineCode = data.positionLineCode
+          ? data.positionLineCode + '-'
+          : '';
+        // const positionFactoryCode = data.positionFactoryCode ? data.positionFactoryCode : ''
+        const equiLocationCode =
+          positionWorkshopCode + positionFarmCode + positionLineCode;
+        return { equiLocation, equiLocationCode };
+      },
+      // 设备列表树点击
+      handleNodeClick (data, node) {
+        console.log('设备列表树点击', data);
+        this.currentNode = data;
+        const { equiLocation, equiLocationCode } = this.getEquiLocation(data);
+        this.equipmentInfo = {
+          equiCode: data.code,
+          equiName: data.name,
+          equiId: data.id,
+          equiModel: data.modelType,
+          equiLocation,
+          equiLocationCode
+        };
+        // 保存当前点击的设备列表某节点的index,在添加操作事项的时候,可以将事项list放到对应的节点对象中,以及切换节点的时候回显事项list
+        this.currentEquItemIndex = this.addForm.planEquiList.findIndex(
+          (item) => item.code === data.code
+        );
+        this.clickedTreeNode = true;
+        this.addForm.planEquiList[this.currentEquItemIndex]['equiLocation'] =
+          equiLocation;
+        this.addForm.planEquiList[this.currentEquItemIndex][
+          'equiLocationCode'
+        ] = equiLocationCode;
+        // 切换设备清空操作事项
+        // this.addForm.planEquiList[this.currentEquItemIndex].itemList = []
+        // this.addForm.planEquiList[this.currentEquItemIndex].partList = []
+      },
+      // 规则名称下拉触发
+      handleRuleNameChange (val) {
+        this._getMatterRulesDetails(val);
+      },
+      // 封装 - 获取规则下面的详情数据及事项
+      async _getMatterRulesDetails (val) {
+        const res = await contentConfig.getInfoNew(val);
+        if (res.success) {
+          this.matterRulesList = res.data.ruleDetailList;
+          // console.log('事项规则:', this.matterRulesList)
+        }
+      },
 
-    // 获取审核人列表、巡点检人员
-    async getUserList (params) {
-      try {
-        let data = { status: 1, page: 1, size: 999999 }
-        // 如果传了参数就是获取巡点检人员数据
-        if (params) {
-          data = Object.assign(data, params)
+      // 从事项弹窗将数据丢到事项配置
+      ruleItemSelectionSubmit (list) {
+        if (list) {
+          if (
+            !this.addForm.planEquiList[this.currentEquItemIndex]['itemList']
+          ) {
+            this.addForm.planEquiList[this.currentEquItemIndex]['itemList'] =
+              [];
+          }
+          this.addForm.planEquiList[this.currentEquItemIndex]['itemList'] =
+            list.map((item) => {
+              return {
+                id: item.id,
+                name: item.name,
+                content: item.content,
+                norm: item.norm
+              };
+            });
+          this.$forceUpdate();
         }
-        const res = await user.list(data)
-        if (params) {
-          this.executorList = res.data.items
+      },
+      // 添加操作事项
+      addOperationItems () {
+        if (!this.clickedTreeNode) {
+          return this.$message.warning('请选择设备分类!');
+        }
+        if (!this.addForm.ruleId) {
+          return this.$message.warning('请选择规则名称!');
+        }
+        this.$refs.ruleItemSelectionRef.open();
+        if (this.addForm.planEquiList[this.currentEquItemIndex]['itemList']) {
+          this.selectedMatter =
+            this.addForm.planEquiList[this.currentEquItemIndex]['itemList'];
         } else {
-          this.uerList = res.data.items
+          this.selectedMatter = [];
         }
-      } catch (error) {}
-    },
-    // 获取部门列表数据
-    async getDeptList () {
-      try {
-        let tree = await dept.tree()
-        this.deptList = tree.data
-      } catch (error) {}
-    },
-    //选择部门(搜索)
-    searchDeptNodeClick (info) {
-      if (info) {
-        this.addForm.executorDeptCode = info.code
-        this.addForm.executorDeptName = info.name
-        // this.addForm.executorId = info.executorId
-        this.addForm.executorName = info.executorName
-        this.addForm.executorPhone = info.executorPhone
-        // 根据部门获取人员
-        const params = { deptCode: info.code, status: 1 }
-        this.getUserList(params)
-      } else {
-        this.addForm.executorDeptCode = null
-      }
-    },
-    // 封装 - 获取设备位置名称和code方法
-    getEquiLocation(data) {
-      // 设备位置名称
-      const positionWorkshop = data.positionWorkshop ? data.positionWorkshop + '-' : ''
-      const positionFarm = data.positionFarm ? data.positionFarm + '-' : ''
-      const positionLine = data.positionLine ? data.positionLine + '-' : ''
-      const positiondetail = data.detailLocation ? data.detailLocation : ''
-      const equiLocation = positionWorkshop + positionFarm + positionLine + positiondetail
-      // 设备位置编码
-      const positionWorkshopCode = data.positionWorkshopCode ? data.positionWorkshopCode + '-' : ''
-      const positionFarmCode = data.positionFarmCode ? data.positionFarmCode + '-' : ''
-      const positionLineCode = data.positionLineCode ? data.positionLineCode + '-' : ''
-      // const positionFactoryCode = data.positionFactoryCode ? data.positionFactoryCode : ''
-      const equiLocationCode = positionWorkshopCode + positionFarmCode + positionLineCode 
-      return { equiLocation, equiLocationCode }
-    },
-    // 设备列表树点击
-    handleNodeClick (data, node) {
-      console.log('设备列表树点击',data)
-      this.currentNode = data
-      const { equiLocation, equiLocationCode } = this.getEquiLocation(data)
-      this.equipmentInfo = {
-        equiCode: data.code,
-        equiName: data.name,
-        equiId: data.id,
-        equiModel: data.modelType,
-        equiLocation,
-        equiLocationCode
-      }
-      // 保存当前点击的设备列表某节点的index,在添加操作事项的时候,可以将事项list放到对应的节点对象中,以及切换节点的时候回显事项list
-      this.currentEquItemIndex = this.addForm.planEquiList.findIndex(
-        item => item.code ===  data.code
-      )
-      this.clickedTreeNode = true
-      this.addForm.planEquiList[this.currentEquItemIndex]['equiLocation'] = equiLocation
-      this.addForm.planEquiList[this.currentEquItemIndex]['equiLocationCode'] = equiLocationCode
-      // 切换设备清空操作事项
-      // this.addForm.planEquiList[this.currentEquItemIndex].itemList = []
-      // this.addForm.planEquiList[this.currentEquItemIndex].partList = []
-    },
-    // 规则名称下拉触发
-    handleRuleNameChange (val) {
-      this._getMatterRulesDetails(val)
-    },
-    // 封装 - 获取规则下面的详情数据及事项
-    async _getMatterRulesDetails (val) {
-      const res = await contentConfig.getInfoNew(val)
-      if (res.success) {
-        this.matterRulesList = res.data.ruleDetailList
-        // console.log('事项规则:', this.matterRulesList)
-      }
-    },
-
-    // 从事项弹窗将数据丢到事项配置
-    ruleItemSelectionSubmit (list) {
-      if(list){
-         if (!this.addForm.planEquiList[this.currentEquItemIndex]['itemList']) {
-           this.addForm.planEquiList[this.currentEquItemIndex]['itemList'] = []
-         }
-         this.addForm.planEquiList[this.currentEquItemIndex]['itemList'] =
-           list.map(item => {
-             return {
-               id: item.id,
-               name: item.name,
-               content: item.content,
-               norm: item.norm
-             }
-           })
-         this.$forceUpdate()
-      }
-    },
-    // 添加操作事项
-    addOperationItems () {
-      if (!this.clickedTreeNode) {
-        return this.$message.warning('请选择设备分类!')
-      }
-      if (!this.addForm.ruleId) {
-        return this.$message.warning('请选择规则名称!')
-      }
-      this.$refs.ruleItemSelectionRef.open()
-      if (this.addForm.planEquiList[this.currentEquItemIndex]['itemList']) {
-        this.selectedMatter =
-          this.addForm.planEquiList[this.currentEquItemIndex]['itemList']
-      } else {
-        this.selectedMatter = []
-      }
-    },
+      },
 
-    // 删除操作事项
-    handleDeleteOperationItem (index) {
-      if(this.addForm.planEquiList[this.currentEquItemIndex]['itemList']){
-         this.addForm.planEquiList[this.currentEquItemIndex]['itemList'].splice(
-            index,
-            1
-          )
-      }
-    },
+      // 删除操作事项
+      handleDeleteOperationItem (index) {
+        if (this.addForm.planEquiList[this.currentEquItemIndex]['itemList']) {
+          this.addForm.planEquiList[this.currentEquItemIndex][
+            'itemList'
+          ].splice(index, 1);
+        }
+      },
 
-    // 添加备品备件
-    addSpareItems () {
-      if (!this.clickedTreeNode) {
-        return this.$message.warning('请选择设备分类!')
-      }
-      if (!this.addForm.ruleId) {
-        return this.$message.warning('请选择规则名称!')
-      }
-      this.$refs.addSpareDialogRef.open()
-      if (this.addForm.planEquiList[this.currentEquItemIndex]['partList']) {
-        this.selectedSpare =
-          this.addForm.planEquiList[this.currentEquItemIndex]['partList']
-      } else {
-        this.selectedSpare = []
-      }
-    },
+      // 添加备品备件
+      addSpareItems () {
+        if (!this.clickedTreeNode) {
+          return this.$message.warning('请选择设备分类!');
+        }
+        if (!this.addForm.ruleId) {
+          return this.$message.warning('请选择规则名称!');
+        }
+        this.$refs.addSpareDialogRef.open();
+        if (this.addForm.planEquiList[this.currentEquItemIndex]['partList']) {
+          this.selectedSpare =
+            this.addForm.planEquiList[this.currentEquItemIndex]['partList'];
+        } else {
+          this.selectedSpare = [];
+        }
+      },
 
-    // 从备品备件弹窗将数据丢到备品备件配置
-    spareItemSelectSubmit (list) {
-      // console.log('备品备件:', list)
-      // this.addForm.planEquiList[this.currentEquItemIndex]['partList'] =
-      //   list.map(item => {
-      //     return {
-      //       id: item.id,
-      //       code: item.code,
-      //       name: item.name,
-      //       model: item.model,
-      //       num: item.num,
-      //       unit: item.unit,
-      //       amount: item.amount
-      //     }
-      //   })
-      this.addForm.planEquiList[this.currentEquItemIndex]['partList'] = [
-        ...deepClone(list)
-      ]
-      this.$forceUpdate()
-    },
+      // 从备品备件弹窗将数据丢到备品备件配置
+      spareItemSelectSubmit (list) {
+        // console.log('备品备件:', list)
+        // this.addForm.planEquiList[this.currentEquItemIndex]['partList'] =
+        //   list.map(item => {
+        //     return {
+        //       id: item.id,
+        //       code: item.code,
+        //       name: item.name,
+        //       model: item.model,
+        //       num: item.num,
+        //       unit: item.unit,
+        //       amount: item.amount
+        //     }
+        //   })
+        this.addForm.planEquiList[this.currentEquItemIndex]['partList'] = [
+          ...deepClone(list)
+        ];
+        this.$forceUpdate();
+      },
 
-    // 删除备品备件
-    handleDeleteSpareItem (index) {
-      this.addForm.planEquiList[this.currentEquItemIndex]['partList'].splice(
-        index,
-        1
-      )
-      this.changeNum()
-    },
+      // 删除备品备件
+      handleDeleteSpareItem (index) {
+        this.addForm.planEquiList[this.currentEquItemIndex]['partList'].splice(
+          index,
+          1
+        );
+        this.changeNum();
+      },
 
-    // 改变input数据重新计算总费用
-    changeNum(){
-        let applayList = this.addForm.planEquiList[this.currentEquItemIndex].partList
-        let total = 0
-        applayList.map(item=>{
-           if(item.hasOwnProperty('num')&&item.num!=''){
-              switch (item.univalenceUnit) {
-                case 'wanyuan': {
-                  item.chengs = 10000
-                  break;
-                }
-                case 'yuan': {
-                  item.chengs = 1
-                  break;
-                }
-                default:
-                  break;
+      // 改变input数据重新计算总费用
+      changeNum () {
+        let applayList =
+          this.addForm.planEquiList[this.currentEquItemIndex].partList;
+        let total = 0;
+        applayList.map((item) => {
+          if (item.hasOwnProperty('num') && item.num != '') {
+            switch (item.univalenceUnit) {
+              case 'wanyuan': {
+                item.chengs = 10000;
+                break;
               }
-              total = total + item.num*item.univalence*item.chengs
-           }
-        })
-        this.$set(this.addForm.planEquiList[this.currentEquItemIndex],'totalCost',total)
-    },
-    // 提交
-    submit () {
-      this.$refs.addFormRef.validate(async valid => {
-        if (valid) {
-          try {
-            if(!this.addForm.planEquiList[this.currentEquItemIndex]['itemList']){
-               this.$message.warning('请添加操作事项!')
-               return;
-            }
-            // this.addForm.planEquiList = this.addForm.planEquiList.filter(
-            //   item => item.itemList
-            // )
-            this.addForm.planEquiList = this.addForm.planEquiList.map(item => {
-              return {
-                equiCode: item.code,
-                equiName: item.name,
-                equiId: item.id,
-                equiModel: item.modelType,
-                equiLocation: item.equiLocation,
-                equiLocationCode: item.equiLocationCode,
-                itemList: item.itemList?item.itemList:[],
-                partList: item.partList?item.partList:[],
+              case 'yuan': {
+                item.chengs = 1;
+                break;
               }
-            })
-            if (this.addForm.planType instanceof Object) {
-              this.addForm.planType =
-                this.planRuleTypeObj[this.addForm.planType.code]
+              default:
+                break;
             }
-            let arr = []
-            this.addForm.planEquiList.map((item)=>{
-                if(item.itemList.length||item.partList.length){
-                  arr.push(item)
+            total = total + item.num * item.univalence * item.chengs;
+          }
+        });
+        this.$set(
+          this.addForm.planEquiList[this.currentEquItemIndex],
+          'totalCost',
+          total
+        );
+      },
+      // 提交
+      submit () {
+        this.$refs.addFormRef.validate(async (valid) => {
+          if (valid) {
+            try {
+              if (
+                !this.addForm.planEquiList[this.currentEquItemIndex]['itemList']
+              ) {
+                this.$message.warning('请添加操作事项!');
+                return;
+              }
+              // this.addForm.planEquiList = this.addForm.planEquiList.filter(
+              //   item => item.itemList
+              // )
+              this.addForm.planEquiList = this.addForm.planEquiList.map(
+                (item) => {
+                  return {
+                    equiCode: item.code,
+                    equiName: item.name,
+                    equiId: item.id,
+                    equiModel: item.modelType,
+                    equiLocation: item.equiLocation,
+                    equiLocationCode: item.equiLocationCode,
+                    itemList: item.itemList ? item.itemList : [],
+                    partList: item.partList ? item.partList : []
+                  };
+                }
+              );
+              if (this.addForm.planType instanceof Object) {
+                this.addForm.planType =
+                  this.planRuleTypeObj[this.addForm.planType.code];
+              }
+              let arr = [];
+              this.addForm.planEquiList.map((item) => {
+                if (item.itemList.length || item.partList.length) {
+                  arr.push(item);
                 }
-            })
+              });
 
-            this.addForm.planEquiList = arr
-            // 深拷贝this.addForm.planEquiList给每一个备品备件list添上设备code
-            let newArr = JSON.parse(JSON.stringify(this.addForm.planEquiList))
-            let newData = [];//新的数组
-            for (let i = 0; i < newArr.length; i++) {
+              this.addForm.planEquiList = arr;
+              // 深拷贝this.addForm.planEquiList给每一个备品备件list添上设备code
+              let newArr = JSON.parse(
+                JSON.stringify(this.addForm.planEquiList)
+              );
+              let newData = []; //新的数组
+              for (let i = 0; i < newArr.length; i++) {
                 for (let j = 0; j < newArr[i].partList.length; j++) {
-                    delete newArr[i].partList[j].createTime
-                    delete newArr[i].partList[j].id
-                    newArr[i].partList[j].equipmentCode = newArr[i].equiCode
+                  delete newArr[i].partList[j].createTime;
+                  delete newArr[i].partList[j].id;
+                  newArr[i].partList[j].equipmentCode = newArr[i].equiCode;
                 }
                 newData.push(newArr[i].partList);
-            }
-            // 将newData拼接成一个新数组赋值给后端接收字段
-            let applyList = []
-            newData.map((item,index)=>{
-               applyList = applyList.concat(item)
-            })
-            this.addForm.sparePartsApply.sparePartsApplyDetailList = applyList
-            const res = await handleSave(this.addForm)
-            if (res.success) {
-              const type = this.dialogTitle.includes('新增') ? '新增' : '编辑'
-              this.handleClose()
-              this.$message.success(type + '成功!')
-              this.$emit('refreshList')
-            }
-          } catch (error) {}
-        }
-      })
+              }
+              // 将newData拼接成一个新数组赋值给后端接收字段
+              let applyList = [];
+              newData.map((item, index) => {
+                applyList = applyList.concat(item);
+              });
+              this.addForm.sparePartsApply.sparePartsApplyDetailList =
+                applyList;
+              const res = await handleSave(this.addForm);
+              if (res.success) {
+                const type = this.dialogTitle.includes('新增')
+                  ? '新增'
+                  : '编辑';
+                this.handleClose();
+                this.$message.success(type + '成功!');
+                this.$emit('refreshList');
+              }
+            } catch (error) {}
+          }
+        });
+      }
     }
-  }
-}
+  };
 </script>
 
 <style lang="scss" scoped>
-::v-deep .el-form {
-  .el-form-item {
-    margin-bottom: 14px;
-  }
-  .el-form-item__error {
-    padding-top: 0;
-  }
-}
-.equipment_box {
-  display: flex;
-  .left_aside {
-    width: 300px;
-    border: 1px solid #797979;
-    margin-right: 5px;
-    .equipment_list_title {
-      height: 24px;
-      line-height: 24px;
-      text-align: center;
-      background-color: #d7d7d7;
-      color: #000;
-      font-weight: 700;
-    }
-    .equipment_tree {
-      height: 510px;
-      overflow: auto;
-    }
-    ::v-deep .el-tree-node__expand-icon.el-icon-caret-right {
-      padding: 0;
+  ::v-deep .el-form {
+    .el-form-item {
+      margin-bottom: 14px;
     }
-    ::v-deep
-      .el-tree--highlight-current
-      .el-tree-node.is-current
-      > .el-tree-node__content {
-      background-color: #d7f1fd !important;
+    .el-form-item__error {
+      padding-top: 0;
     }
   }
-  .right_aside {
-    flex: 1;
-    border: 1px solid #797979;
-    padding: 10px;
-    .equipment_info {
-      display: flex;
-      flex-wrap: wrap;
-      border: 1px solid #ddd;
-      .item_info {
-        width: 33%;
+  .equipment_box {
+    display: flex;
+    .left_aside {
+      width: 300px;
+      border: 1px solid #797979;
+      margin-right: 5px;
+      .equipment_list_title {
         height: 24px;
         line-height: 24px;
+        text-align: center;
+        background-color: #d7d7d7;
+        color: #000;
+        font-weight: 700;
+      }
+      .equipment_tree {
+        height: 510px;
+        overflow: auto;
+      }
+      ::v-deep .el-tree-node__expand-icon.el-icon-caret-right {
+        padding: 0;
+      }
+      ::v-deep
+        .el-tree--highlight-current
+        .el-tree-node.is-current
+        > .el-tree-node__content {
+        background-color: #d7f1fd !important;
+      }
+    }
+    .right_aside {
+      flex: 1;
+      border: 1px solid #797979;
+      padding: 10px;
+      .equipment_info {
         display: flex;
-        .item_label {
-          width: 90px;
-          text-align: center;
-          background-color: #f2f2f2;
-          font-weight: 700;
-        }
-        .item_value {
-          border-bottom: 1px solid #f2f2f2;
-          flex: 1;
-          padding-left: 5px;
-        }
-        &:last-child {
-          width: 100%;
+        flex-wrap: wrap;
+        border: 1px solid #ddd;
+        .item_info {
+          width: 33%;
+          height: 24px;
+          line-height: 24px;
+          display: flex;
+          .item_label {
+            width: 90px;
+            text-align: center;
+            background-color: #f2f2f2;
+            font-weight: 700;
+          }
           .item_value {
-            border: 0;
+            border-bottom: 1px solid #f2f2f2;
+            flex: 1;
+            padding-left: 5px;
+          }
+          &:last-child {
+            width: 100%;
+            .item_value {
+              border: 0;
+            }
           }
         }
       }
     }
   }
-}
-.dialog_footer {
-  text-align: center;
-}
+  .dialog_footer {
+    text-align: center;
+  }
 </style>