浏览代码

feat: 添加设备BOM绑定与解绑功能

yusheng 2 月之前
父节点
当前提交
aa84ad424f

+ 17 - 0
src/api/ledgerAssets/index.js

@@ -158,3 +158,20 @@ export async function importCategorySparePart(data) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+//绑定设备BOM与实体关系
+export async function bomSubstanceBind(data) {
+  const res = await request.post(`/main/bomSubstance/bind`, data);
+  if (res.data.code == 0) {
+    return res.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+//解除绑定设备BOM与实体关系
+export async function batchUnbind(data) {
+  const res = await request.post(`/main/bomSubstance/batchUnbind`, data);
+  if (res.data.code == 0) {
+    return res.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+

+ 2 - 2
src/views/ledgerAssets/components/MaterialAdd.vue

@@ -18,7 +18,7 @@
         :selection.sync="selection"
         row-key="id"
         :initLoad="false"
-        :needPage="false"
+        @cell-click="cellClick"
       >
         <template v-slot:modelType="{ row }">
           <span>{{ row.category.modelType }}</span>
@@ -30,7 +30,7 @@
           <span>{{ row.position[0] && row.position[0].pathName }}</span>
         </template>
         <template v-slot:action="{ row }">
-          <el-radio class="radio" v-model="radio" :label="row.id">
+          <el-radio class="radio" v-model="radio" :disabled="row.isBindMainDevice"  :label="row.id">
             <i></i>
           </el-radio>
         </template>

+ 40 - 6
src/views/ledgerAssets/equipment/components/detailedList.vue

@@ -108,10 +108,21 @@
         </el-input>
       </template>
       <template v-slot:action="{ row }">
-        <el-link type="primary" :underline="false" @click="open(row)"
+        <el-link
+          type="primary"
+          :underline="false"
+          @click="open(row)"
+          v-if="!row.bomCategorySubstanceId"
           >关联设备实例</el-link
-        ></template
-      >
+        >
+        <el-link
+          type="primary"
+          :underline="false"
+          @click="batchUnbind(row)"
+          v-else
+          >解除绑定</el-link
+        >
+      </template>
     </ele-pro-table>
     <print ref="printRef"></print>
     <MaterialAdd
@@ -125,7 +136,7 @@
   import BOMSearch from './BOM-search.vue';
   import { getBomPageCategoryId, contactList } from '@/api/material/BOM';
   import { getByCode } from '@/api/system/dictionary-data';
-
+  import { bomSubstanceBind, batchUnbind } from '@/api/ledgerAssets';
   import print from './print.vue';
   import MaterialAdd from '@/views/ledgerAssets/components/MaterialAdd.vue';
   export default {
@@ -279,7 +290,7 @@
         newTreeId: null,
 
         dictList: [],
-
+        bomId: '',
         checkRadioData: []
       };
     },
@@ -308,6 +319,10 @@
       codes: {
         type: String,
         default: ''
+      },
+      substanceId: {
+        type: String,
+        default: ''
       }
     },
 
@@ -343,9 +358,28 @@
         });
       },
       open(row) {
+        this.bomId = row.id;
         this.$refs.MaterialAdd.open(row);
       },
-      chooseEquipment(row) {},
+      chooseEquipment(row) {
+        bomSubstanceBind({
+          bomCategoryId: this.bomId,
+          bomCategorySubstanceId: row.id,
+          substanceId: this.substanceId
+        }).then((res) => {
+          this.reload();
+          this.$message.success('操作成功!');
+        });
+      },
+      batchUnbind(row) {
+        batchUnbind({
+          bomCategorySubstanceIds: [row.bomCategorySubstanceId],
+          substanceId: this.substanceId
+        }).then((res) => {
+          this.reload();
+          this.$message.success('解绑成功!');
+        });
+      },
       /* 刷新表格 */
       reload(where) {
         this.$refs.table.reload({ where });

+ 635 - 632
src/views/ledgerAssets/equipment/components/equipment-list.vue

@@ -1,632 +1,635 @@
-<template>
-  <div>
-    <equipment-search
-      @search="reload"
-      :networkCounts="networkCounts"
-      ref="search"
-    />
-    <!-- 数据表格 -->
-    <ele-pro-table
-      ref="table"
:pageSizes="tablePageSizes"
-      :columns="columns"
-      :datasource="datasource"
-      height="calc(100vh - 500px)"
-      full-height="calc(100vh - 115px)"
-      tool-class="ele-toolbar-form"
-      cache-key="systemOrgUserTable"
-      :initLoad="false"
-      @select="selectChange"
-      @select-all="changeSelectAll"
-    >
-      <!-- 表头工具栏 -->
-      <template v-slot:toolbar="{ row }" v-if="!$route.query.isDrawer">
-        <el-button
-          size="small"
-          type="primary"
-          icon="el-icon-plus"
-          class="ele-btn-icon"
-          @click="add"
-          v-if="$hasPermission('main:substance:save')"
-        >
-          新建
-        </el-button>
-        <el-button
-          size="small"
-          icon="el-icon-download"
-          class="ele-btn-icon"
-          type="primary"
-          @click="exportFile"
-          v-if="$hasPermission('main:exportFile:save')"
-        >
-          导出
-        </el-button>
-        <el-button
-          size="small"
-          :disabled="checkRadioData.length == 0"
-          icon="el-icon-set-up"
-          class="ele-btn-icon"
-          @click="allPrinting()"
-        >
-          打印条码
-        </el-button>
-        <el-button
-          size="small"
-          :disabled="checkRadioData.length == 0"
-          icon="el-icon-thumb"
-          class="ele-btn-icon"
-          @click="moveTo(checkRadioData, 'person')"
-          v-if="$hasPermission('main:substance:update')"
-        >
-          设置片区负责人
-        </el-button>
-        <el-button
-          size="small"
-          :disabled="checkRadioData.length == 0"
-          icon="el-icon-s-tools"
-          class="ele-btn-icon"
-          @click="batchSettings(1)"
-          v-if="$hasPermission('main:substance:update')"
-        >
-          设置权属部门
-        </el-button>
-        <el-button
-          size="small"
-          :disabled="checkRadioData.length == 0"
-          icon="el-icon-setting"
-          class="ele-btn-icon"
-          @click="batchSettings(2)"
-          v-if="$hasPermission('main:substance:update')"
-        >
-          设置使用单位
-        </el-button>
-        <el-button
-          size="small"
-          type="danger"
-          icon="el-icon-delete"
-          class="ele-btn-icon"
-          @click="handlDelete"
-          v-if="$hasPermission('main:substance:delete')"
-          >批量删除</el-button
-        >
-
-        <el-button
-          type="primary"
-          size="small"
-          icon="el-icon-upload2"
-          @click="uploadFile"
-          >导入</el-button
-        >
-        <!-- <el-button
-          size="small"
-          @click="moveTo(checkRadioData, 'move')"
-          :disabled="checkRadioData.length == 0"
-          class="ele-btn-icon"
-          >移动到</el-button
-        > -->
-      </template>
-      <!-- 编码列 -->
-      <template v-slot:code="{ row }" v-if="!$route.query.isDrawer">
-        <el-link type="primary" :underline="false" @click="details(row)">
-          {{ row.code }}
-        </el-link>
-      </template>
-      <!-- 操作列 -->
-      <template v-slot:action="{ row }" v-if="!$route.query.isDrawer">
-        <el-popconfirm
-          class="ele-action"
-          title="确定要删除此设备数据吗?"
-          @confirm="handleRemove(row)"
-          v-if="$hasPermission('main:substance:delete')"
-        >
-          <template v-slot:reference>
-            <el-link type="danger" :underline="false" icon="el-icon-delete"
-              >删除</el-link
-            >
-          </template>
-        </el-popconfirm>
-        <el-link
-          type="primary"
-          :underline="false"
-          icon="el-icon-edit"
-          @click="handEdit(row)"
-          v-if="$hasPermission('main:substance:update')"
-        >
-          编辑
-        </el-link>
-        <el-link type="primary" @click="handelBOM(row)">BOM</el-link>
-      </template>
-    </ele-pro-table>
-
-    <print ref="printRef"></print>
-    <printSr ref="printSrRef"></printSr>
-    <printTg ref="printTgRef"></printTg>
-    <BomDetailsPop ref="bomDrawer"></BomDetailsPop>
-    <batchSetDialog ref="batchSetRef" @success="sucesstion" />
-    <DialogMoveto ref="movetoRef" @success="sucesstion" />
-    <importDialog
-      ref="importDialogRef"
-      @success="reload"
-      :fileUrl="'/main/asset/importTemplate'"
-      :isWeb="false"
-      fileName="设备台账导入模板"
-      apiUrl="/main/asset/importFile"
-      :rootCategoryLevelId="rootId"
-    />
-  </div>
-</template>
-
-<script>
-  import batchSetDialog from './batchSetDialog.vue';
-  import DialogMoveto from './DialogMoveTo.vue';
-
-  import print from '@/views/ledgerAssets/components/print.vue';
-  import printSr from '@/views/ledgerAssets/components/printSr';
-  import printTg from '@/views/ledgerAssets/components/printTg';
-  import { getByCode } from '@/api/system/dictionary-data';
-  import importDialog from '@/components/upload/import-dialog.vue';
-  import {
-    businessStatus,
-    networkStatus,
-    sourceStatus
-  } from '@/utils/dict/warehouse';
-
-  import EquipmentSearch from './equipment-search.vue';
-
-  import {
-    getAssetList,
-    downloadAsset,
-    getNetworkCount,
-    batchDel
-  } from '@/api/ledgerAssets';
-  import dictMixins from '@/mixins/dictMixins';
-  import axios from 'axios';
-  import {
-    API_BASE_URL,
-    TOKEN_HEADER_NAME,
-    LAYOUT_PATH
-  } from '@/config/setting';
-  import { download } from '@/utils/file';
-  import { getToken, setToken } from '@/utils/token-util';
-
-  import BomDetailsPop from '@/views/ledgerAssets/equipment/detailsPop.vue';
-
-  export default {
-    components: {
-      EquipmentSearch,
-      print,
-      printSr,
-      printTg,
-      BomDetailsPop,
-      importDialog,
-      DialogMoveto,
-      batchSetDialog
-    },
-    mixins: [dictMixins],
-    props: {
-      // 类别id
-      categoryId: [Number, String],
-      rootId: [Number, String],
-      current: {
-        typeof: Object,
-        default: {}
-      }
-    },
-    data() {
-      return {
-        businessStatus,
-        networkStatus,
-        assetLevel: [],
-        isConsumer: false,
-        // 表格列配置
-        columns: [
-          {
-            width: 45,
-            type: 'selection',
-            columnKey: 'selection',
-            align: 'center'
-          },
-          {
-            columnKey: 'index',
-            type: 'index',
-            label: '序号',
-            width: 55,
-            align: 'center',
-            showOverflowTooltip: true,
-            fixed: 'left'
-          },
-          {
-            columnKey: 'code',
-            prop: 'code',
-            slot: 'code',
-            label: '编码',
-            showOverflowTooltip: true,
-            minWidth: 180
-          },
-          // {
-          //   columnKey: 'code',
-          //   prop: 'code',
-          //   label: '设备编码',
-          //   showOverflowTooltip: true,
-          //   minWidth: 110,
-          //   slot: 'code'
-          // },
-          {
-            prop: 'category.name',
-            label: '名称',
-            showOverflowTooltip: true,
-            minWidth: 110
-          },
-          {
-            prop: 'fixCode',
-            label: '固资编码',
-            showOverflowTooltip: true,
-            minWidth: 110
-          },
-
-          {
-            prop: 'codeNumber',
-            label: '编号',
-            showOverflowTooltip: true,
-            minWidth: 110
-          },
-          // {
-          //   prop: 'codeNumber',
-          //   label: '编号',
-          //   showOverflowTooltip: true,
-          //   minWidth: 110
-          // },
-
-          {
-            prop: 'category.modelType',
-            label: '型号',
-            showOverflowTooltip: true,
-            minWidth: 110
-          },
-          {
-            prop: 'category.specification',
-            label: '规格',
-            showOverflowTooltip: true,
-            minWidth: 110
-          },
-          {
-            prop: 'workstationInfo.name',
-            label: '工位名称',
-            showOverflowTooltip: true,
-            minWidth: 110
-          },
-          {
-            prop: 'postName',
-            label: '使用单位',
-            showOverflowTooltip: true,
-            minWidth: 110
-          },
-          {
-            prop: 'usePerson',
-            label: '使用人',
-            showOverflowTooltip: true,
-            minWidth: 80
-          },
-          {
-            prop: 'ownershipGroupName',
-            label: '权属部门',
-            showOverflowTooltip: true,
-            minWidth: 110
-          },
-          {
-            prop: 'areaPersonInChargeUserName',
-            label: '片区负责人',
-            showOverflowTooltip: true,
-            minWidth: 150
-          },
-          {
-            prop: 'repairUserName',
-            label: '维修人',
-            showOverflowTooltip: true,
-            minWidth: 150
-          },
-          {
-            prop: 'endTime',
-            label: '有效期结束时间',
-            showOverflowTooltip: true,
-            minWidth: 150
-          },
-          {
-            prop: 'source',
-            label: '生命周期',
-            showOverflowTooltip: true,
-            minWidth: 110,
-            formatter: (_row) => {
-              return sourceStatus[_row.lifeCycle];
-            }
-          },
-          {
-            prop: 'level',
-            label: '级别',
-            showOverflowTooltip: true,
-            minWidth: 110,
-            formatter: (_row) => {
-              if (_row.level) {
-                return this.assetLevel.filter(
-                  (item) => item.id == _row.level
-                )[0]?.name;
-              } else {
-                return '';
-              }
-            }
-          },
-          {
-            prop: 'networkStatus',
-            label: '网络状态',
-            showOverflowTooltip: true,
-            minWidth: 110,
-            formatter: (_row) => {
-              if (_row.networkStatus) {
-                return this.networkStatus.filter(
-                  (item) => item.code == _row.networkStatus
-                )[0].label;
-              } else {
-                return '离线';
-              }
-            }
-          },
-          {
-            prop: 'status',
-            label: '状态',
-            showOverflowTooltip: true,
-            minWidth: 110,
-            formatter: (_row) => {
-              if (_row.status) {
-                return this.businessStatus.filter(
-                  (item) => item.code == _row.status
-                )[0].label;
-              } else {
-                return '空闲';
-              }
-            }
-          },
-          {
-            prop: 'pathName',
-            label: '位置',
-            showOverflowTooltip: true,
-            minWidth: 110,
-            formatter: (_row) => {
-              const positionDetail =
-                _row.position &&
-                _row.position.length != 0 &&
-                _row.position[0].detailPosition
-                  ? _row.position[0].detailPosition
-                  : '-';
-              return _row.deviceLocationName
-                ? _row.deviceLocationName + '-' + positionDetail
-                : '';
-            }
-          },
-          {
-            columnKey: 'action',
-            slot: 'action',
-            label: '操作',
-            minWidth: 170,
-            align: 'center',
-            fixed: 'right'
-          }
-        ],
-        networkCounts: {},
-        checkRadioData: [],
-        QRvisible: false
-      };
-    },
-    computed: {
-      clientEnvironmentId() {
-        console.log('this.$store.state.user.---computed---');
-        console.log(this.$store.state.user);
-        return this.$store.state.user.info.clientEnvironmentId;
-      }
-    },
-    created() {
-      console.log('this.$store.state.user.-------------------');
-      console.log(this.$store.state.user);
-      this.requestDict('网络状态');
-      this.getAssetLevelOptions();
-    },
-    methods: {
-      //导入
-      uploadFile() {
-        this.$refs.importDialogRef.open();
-      },
-      allPrinting() {
-        console.log('this.clientEnvironmentId-------------');
-        console.log(this.clientEnvironmentId);
-        if (this.clientEnvironmentId == 2) {
-          this.$refs.printSrRef.open(this.checkRadioData);
-        } else if (this.clientEnvironmentId == 3) {
-          this.$refs.printTgRef.open(this.checkRadioData);
-        } else {
-          this.$refs.printRef.open(this.checkRadioData);
-        }
-      },
-      // 获取资产级别下拉
-      async getAssetLevelOptions() {
-        let { data } = await getByCode('asset_level');
-        this.assetLevel =
-          data.length > 0
-            ? data.map((item) => {
-                return {
-                  name: Object.keys(item)[0],
-                  id: item[Object.keys(item)[0]]
-                };
-              })
-            : [];
-      },
-      // 刷新回调
-      sucesstion(is) {
-        console.log(is);
-        if (is) {
-          this.reload();
-        }
-        this.checkRadioData = [];
-      },
-      // 移动到
-      moveTo(arr, type) {
-        this.$refs.movetoRef.open(arr, this.current, type);
-      },
-      // 全选
-      changeSelectAll(arr) {
-        console.log(arr);
-        if (arr.length != 0) {
-          this.checkRadioData = arr;
-        } else {
-          this.checkRadioData = [];
-        }
-      },
-      selectChange(selection, row) {
-        if (selection.length != 0) {
-          this.checkRadioData = selection;
-        } else {
-          this.checkRadioData = [];
-        }
-      },
-      handlDelete() {
-        if (this.checkRadioData.length == 0) {
-          this.$message.warning('请至少选择一条数据');
-          return;
-        }
-        if (this.checkRadioData.length != 0) {
-          this.$confirm('是否删除?', '提示', {
-            confirmButtonText: '确定',
-            cancelButtonText: '取消',
-            type: 'warning'
-          })
-            .then(async () => {
-              const paramsArr = this.checkRadioData.map((item) => {
-                return item.id;
-              });
-              await batchDel(paramsArr);
-              this.$message.success('操作成功');
-              this.sucesstion(true);
-            })
-            .catch(() => {});
-        }
-      },
-      async handleRemove(row) {
-        let arr = [row.id];
-        const res = await batchDel(arr);
-        if (res) {
-          this.$message.success('操作成功');
-          this.sucesstion(true);
-        }
-      },
-      /* 表格数据源 */
-      datasource({ page, limit, where, order }) {
-        console.log('------reload-------');
-        // this.getNetWork(page, limit, where, order);
-        return getAssetList({
-          ...where,
-          ...order,
-          pageNum: page,
-          size: limit,
-          categoryLevelId: this.categoryId,
-          rootCategoryLevelId: this.rootId
-        });
-      },
-      async getNetWork(page, limit, where, order) {
-        const res = await getNetworkCount({
-          ...where,
-          ...order,
-          pageNum: page,
-          size: limit,
-          categoryLevelId: this.categoryId,
-          rootCategoryLevelId: this.rootId
-        });
-        this.networkCounts = res;
-        console.log(res, 'resresresresresresresresresresresresresres');
-      },
-      /* 刷新表格 */
-      reload(where) {
-        this.$refs.table.reload({ pageNum: 1, where: where });
-      },
-      // 跳转到详情页
-      details({ id, code, name }) {
-        this.$router.push({
-          path: '/ledgerAssets/equipment/detail',
-          query: {
-            id,
-            code,
-            name
-          }
-        });
-      },
-      // 跳转到编辑
-      handEdit({ id }) {
-        this.$router.push({
-          path: '/ledgerAssets/equipment/edit',
-          query: {
-            id
-          }
-        });
-      },
-      // 跳转到详情页
-      add() {
-        this.$router.push({
-          path: '/ledgerAssets/equipment/edit'
-        });
-      },
-      exportFile() {
-        let params = {
-          ...this.$refs.search.where,
-          exportType: 1,
-          categoryLevelId: this.categoryId,
-          rootCategoryLevelId: this.rootId
-        };
-        // downloadAsset(params, '设备台账导出数据');
-        axios({
-          url: `${API_BASE_URL}/main/asset/page/export`,
-          method: 'post',
-          responseType: 'blob',
-          headers: {
-            Authorization: getToken()
-          },
-          data: params
-        }).then((res) => {
-          download(res.data, '设备台账导出数据');
-        });
-      },
-      handelBOM(row) {
-        let rowData = {
-          categoryId: row.category.id,
-          categoryName: row.categoryName,
-          code: row.code,
-          versions: row.versions,
-          rootPathIdParent: row.category.categoryLevelPathIdParent,
-          isProduct: true,
-          bomType: '1',
-          isTemp: row.isTemp
-        };
-        this.$refs.bomDrawer.open(rowData);
-      },
-
-      batchSettings(type) {
-        let ids = this.checkRadioData.map((item) => {
-          return item.id;
-        });
-        this.$refs.batchSetRef.open(type, ids);
-        console.log(this.checkRadioData, 'checkRadioData 123');
-      }
-    },
-    watch: {
-      // 监听类别id变化
-      categoryId() {
-        this.reload();
-      }
-    }
-  };
-</script>
-<style lang="scss" scoped>
-  @media print {
-    #printSection {
-      font-size: 34px;
-      span {
-        font-size: 34px;
-      }
-    }
-  }
-</style>
+<template>
+  <div>
+    <equipment-search
+      @search="reload"
+      :networkCounts="networkCounts"
+      ref="search"
+    />
+    <!-- 数据表格 -->
+    <ele-pro-table
+      ref="table"
+:pageSizes="tablePageSizes"
+      :columns="columns"
+      :datasource="datasource"
+      height="calc(100vh - 500px)"
+      full-height="calc(100vh - 115px)"
+      tool-class="ele-toolbar-form"
+      cache-key="systemOrgUserTable"
+      :initLoad="false"
+      @select="selectChange"
+      @select-all="changeSelectAll"
+    >
+      <!-- 表头工具栏 -->
+      <template v-slot:toolbar="{ row }" v-if="!$route.query.isDrawer">
+        <el-button
+          size="small"
+          type="primary"
+          icon="el-icon-plus"
+          class="ele-btn-icon"
+          @click="add"
+          v-if="$hasPermission('main:substance:save')"
+        >
+          新建
+        </el-button>
+        <el-button
+          size="small"
+          icon="el-icon-download"
+          class="ele-btn-icon"
+          type="primary"
+          @click="exportFile"
+          v-if="$hasPermission('main:exportFile:save')"
+        >
+          导出
+        </el-button>
+        <el-button
+          size="small"
+          :disabled="checkRadioData.length == 0"
+          icon="el-icon-set-up"
+          class="ele-btn-icon"
+          @click="allPrinting()"
+        >
+          打印条码
+        </el-button>
+        <el-button
+          size="small"
+          :disabled="checkRadioData.length == 0"
+          icon="el-icon-thumb"
+          class="ele-btn-icon"
+          @click="moveTo(checkRadioData, 'person')"
+          v-if="$hasPermission('main:substance:update')"
+        >
+          设置片区负责人
+        </el-button>
+        <el-button
+          size="small"
+          :disabled="checkRadioData.length == 0"
+          icon="el-icon-s-tools"
+          class="ele-btn-icon"
+          @click="batchSettings(1)"
+          v-if="$hasPermission('main:substance:update')"
+        >
+          设置权属部门
+        </el-button>
+        <el-button
+          size="small"
+          :disabled="checkRadioData.length == 0"
+          icon="el-icon-setting"
+          class="ele-btn-icon"
+          @click="batchSettings(2)"
+          v-if="$hasPermission('main:substance:update')"
+        >
+          设置使用单位
+        </el-button>
+        <el-button
+          size="small"
+          type="danger"
+          icon="el-icon-delete"
+          class="ele-btn-icon"
+          @click="handlDelete"
+          v-if="$hasPermission('main:substance:delete')"
+          >批量删除</el-button
+        >
+
+        <el-button
+          type="primary"
+          size="small"
+          icon="el-icon-upload2"
+          @click="uploadFile"
+          >导入</el-button
+        >
+        <!-- <el-button
+          size="small"
+          @click="moveTo(checkRadioData, 'move')"
+          :disabled="checkRadioData.length == 0"
+          class="ele-btn-icon"
+          >移动到</el-button
+        > -->
+      </template>
+      <!-- 编码列 -->
+      <template v-slot:code="{ row }" v-if="!$route.query.isDrawer">
+        <el-link type="primary" :underline="false" @click="details(row)">
+          {{ row.code }}
+        </el-link>
+      </template>
+      <!-- 操作列 -->
+      <template v-slot:action="{ row }" v-if="!$route.query.isDrawer">
+        <el-popconfirm
+          class="ele-action"
+          title="确定要删除此设备数据吗?"
+          @confirm="handleRemove(row)"
+          v-if="$hasPermission('main:substance:delete')"
+        >
+          <template v-slot:reference>
+            <el-link type="danger" :underline="false" icon="el-icon-delete"
+              >删除</el-link
+            >
+          </template>
+        </el-popconfirm>
+        <el-link
+          type="primary"
+          :underline="false"
+          icon="el-icon-edit"
+          @click="handEdit(row)"
+          v-if="$hasPermission('main:substance:update')"
+        >
+          编辑
+        </el-link>
+        <el-link type="primary" @click="handelBOM(row)">BOM</el-link>
+      </template>
+    </ele-pro-table>
+
+    <print ref="printRef"></print>
+    <printSr ref="printSrRef"></printSr>
+    <printTg ref="printTgRef"></printTg>
+    <BomDetailsPop ref="bomDrawer"></BomDetailsPop>
+    <batchSetDialog ref="batchSetRef" @success="sucesstion" />
+    <DialogMoveto ref="movetoRef" @success="sucesstion" />
+    <importDialog
+      ref="importDialogRef"
+      @success="reload"
+      :fileUrl="'/main/asset/importTemplate'"
+      :isWeb="false"
+      fileName="设备台账导入模板"
+      apiUrl="/main/asset/importFile"
+      :rootCategoryLevelId="rootId"
+    />
+  </div>
+</template>
+
+<script>
+  import batchSetDialog from './batchSetDialog.vue';
+  import DialogMoveto from './DialogMoveTo.vue';
+
+  import print from '@/views/ledgerAssets/components/print.vue';
+  import printSr from '@/views/ledgerAssets/components/printSr';
+  import printTg from '@/views/ledgerAssets/components/printTg';
+  import { getByCode } from '@/api/system/dictionary-data';
+  import importDialog from '@/components/upload/import-dialog.vue';
+  import {
+    businessStatus,
+    networkStatus,
+    sourceStatus
+  } from '@/utils/dict/warehouse';
+
+  import EquipmentSearch from './equipment-search.vue';
+
+  import {
+    getAssetList,
+    downloadAsset,
+    getNetworkCount,
+    batchDel
+  } from '@/api/ledgerAssets';
+  import dictMixins from '@/mixins/dictMixins';
+  import axios from 'axios';
+  import {
+    API_BASE_URL,
+    TOKEN_HEADER_NAME,
+    LAYOUT_PATH
+  } from '@/config/setting';
+  import { download } from '@/utils/file';
+  import { getToken, setToken } from '@/utils/token-util';
+
+  import BomDetailsPop from '@/views/ledgerAssets/equipment/detailsPop.vue';
+
+  export default {
+    components: {
+      EquipmentSearch,
+      print,
+      printSr,
+      printTg,
+      BomDetailsPop,
+      importDialog,
+      DialogMoveto,
+      batchSetDialog
+    },
+    mixins: [dictMixins],
+    props: {
+      // 类别id
+      categoryId: [Number, String],
+      rootId: [Number, String],
+      current: {
+        typeof: Object,
+        default: {}
+      }
+    },
+    data() {
+      return {
+        businessStatus,
+        networkStatus,
+        assetLevel: [],
+        isConsumer: false,
+        // 表格列配置
+        columns: [
+          {
+            width: 45,
+            type: 'selection',
+            columnKey: 'selection',
+            align: 'center'
+          },
+          {
+            columnKey: 'index',
+            type: 'index',
+            label: '序号',
+            width: 55,
+            align: 'center',
+            showOverflowTooltip: true,
+            fixed: 'left'
+          },
+          {
+            columnKey: 'code',
+            prop: 'code',
+            slot: 'code',
+            label: '编码',
+            showOverflowTooltip: true,
+            minWidth: 180
+          },
+          // {
+          //   columnKey: 'code',
+          //   prop: 'code',
+          //   label: '设备编码',
+          //   showOverflowTooltip: true,
+          //   minWidth: 110,
+          //   slot: 'code'
+          // },
+          {
+            prop: 'category.name',
+            label: '名称',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'fixCode',
+            label: '固资编码',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+
+          {
+            prop: 'codeNumber',
+            label: '编号',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          // {
+          //   prop: 'codeNumber',
+          //   label: '编号',
+          //   showOverflowTooltip: true,
+          //   minWidth: 110
+          // },
+
+          {
+            prop: 'category.modelType',
+            label: '型号',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'category.specification',
+            label: '规格',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'workstationInfo.name',
+            label: '工位名称',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'postName',
+            label: '使用单位',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'usePerson',
+            label: '使用人',
+            showOverflowTooltip: true,
+            minWidth: 80
+          },
+          {
+            prop: 'ownershipGroupName',
+            label: '权属部门',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'areaPersonInChargeUserName',
+            label: '片区负责人',
+            showOverflowTooltip: true,
+            minWidth: 150
+          },
+          {
+            prop: 'repairUserName',
+            label: '维修人',
+            showOverflowTooltip: true,
+            minWidth: 150
+          },
+          {
+            prop: 'endTime',
+            label: '有效期结束时间',
+            showOverflowTooltip: true,
+            minWidth: 150
+          },
+          {
+            prop: 'source',
+            label: '生命周期',
+            showOverflowTooltip: true,
+            minWidth: 110,
+            formatter: (_row) => {
+              return sourceStatus[_row.lifeCycle];
+            }
+          },
+          {
+            prop: 'level',
+            label: '级别',
+            showOverflowTooltip: true,
+            minWidth: 110,
+            formatter: (_row) => {
+              if (_row.level) {
+                return this.assetLevel.filter(
+                  (item) => item.id == _row.level
+                )[0]?.name;
+              } else {
+                return '';
+              }
+            }
+          },
+          {
+            prop: 'networkStatus',
+            label: '网络状态',
+            showOverflowTooltip: true,
+            minWidth: 110,
+            formatter: (_row) => {
+              if (_row.networkStatus) {
+                return this.networkStatus.filter(
+                  (item) => item.code == _row.networkStatus
+                )[0].label;
+              } else {
+                return '离线';
+              }
+            }
+          },
+          {
+            prop: 'status',
+            label: '状态',
+            showOverflowTooltip: true,
+            minWidth: 110,
+            formatter: (_row) => {
+              if (_row.status) {
+                return this.businessStatus.filter(
+                  (item) => item.code == _row.status
+                )[0].label;
+              } else {
+                return '空闲';
+              }
+            }
+          },
+          {
+            prop: 'pathName',
+            label: '位置',
+            showOverflowTooltip: true,
+            minWidth: 110,
+            formatter: (_row) => {
+              const positionDetail =
+                _row.position &&
+                _row.position.length != 0 &&
+                _row.position[0].detailPosition
+                  ? _row.position[0].detailPosition
+                  : '-';
+              return _row.deviceLocationName
+                ? _row.deviceLocationName + '-' + positionDetail
+                : '';
+            }
+          },
+          {
+            columnKey: 'action',
+            slot: 'action',
+            label: '操作',
+            minWidth: 170,
+            align: 'center',
+            fixed: 'right'
+          }
+        ],
+        networkCounts: {},
+        checkRadioData: [],
+        QRvisible: false
+      };
+    },
+    computed: {
+      clientEnvironmentId() {
+        console.log('this.$store.state.user.---computed---');
+        console.log(this.$store.state.user);
+        return this.$store.state.user.info.clientEnvironmentId;
+      }
+    },
+    created() {
+      console.log('this.$store.state.user.-------------------');
+      console.log(this.$store.state.user);
+      this.requestDict('网络状态');
+      this.getAssetLevelOptions();
+    },
+    methods: {
+      //导入
+      uploadFile() {
+        this.$refs.importDialogRef.open();
+      },
+      allPrinting() {
+        console.log('this.clientEnvironmentId-------------');
+        console.log(this.clientEnvironmentId);
+        if (this.clientEnvironmentId == 2) {
+          this.$refs.printSrRef.open(this.checkRadioData);
+        } else if (this.clientEnvironmentId == 3) {
+          this.$refs.printTgRef.open(this.checkRadioData);
+        } else {
+          this.$refs.printRef.open(this.checkRadioData);
+        }
+      },
+      // 获取资产级别下拉
+      async getAssetLevelOptions() {
+        let { data } = await getByCode('asset_level');
+        this.assetLevel =
+          data.length > 0
+            ? data.map((item) => {
+                return {
+                  name: Object.keys(item)[0],
+                  id: item[Object.keys(item)[0]]
+                };
+              })
+            : [];
+      },
+      // 刷新回调
+      sucesstion(is) {
+        console.log(is);
+        if (is) {
+          this.reload();
+        }
+        this.checkRadioData = [];
+      },
+      // 移动到
+      moveTo(arr, type) {
+        this.$refs.movetoRef.open(arr, this.current, type);
+      },
+      // 全选
+      changeSelectAll(arr) {
+        console.log(arr);
+        if (arr.length != 0) {
+          this.checkRadioData = arr;
+        } else {
+          this.checkRadioData = [];
+        }
+      },
+      selectChange(selection, row) {
+        if (selection.length != 0) {
+          this.checkRadioData = selection;
+        } else {
+          this.checkRadioData = [];
+        }
+      },
+      handlDelete() {
+        if (this.checkRadioData.length == 0) {
+          this.$message.warning('请至少选择一条数据');
+          return;
+        }
+        if (this.checkRadioData.length != 0) {
+          this.$confirm('是否删除?', '提示', {
+            confirmButtonText: '确定',
+            cancelButtonText: '取消',
+            type: 'warning'
+          })
+            .then(async () => {
+              const paramsArr = this.checkRadioData.map((item) => {
+                return item.id;
+              });
+              await batchDel(paramsArr);
+              this.$message.success('操作成功');
+              this.sucesstion(true);
+            })
+            .catch(() => {});
+        }
+      },
+      async handleRemove(row) {
+        let arr = [row.id];
+        const res = await batchDel(arr);
+        if (res) {
+          this.$message.success('操作成功');
+          this.sucesstion(true);
+        }
+      },
+      /* 表格数据源 */
+      datasource({ page, limit, where, order }) {
+        console.log('------reload-------');
+        // this.getNetWork(page, limit, where, order);
+        return getAssetList({
+          ...where,
+          ...order,
+          pageNum: page,
+          size: limit,
+          categoryLevelId: this.categoryId,
+          rootCategoryLevelId: this.rootId
+        });
+      },
+      async getNetWork(page, limit, where, order) {
+        const res = await getNetworkCount({
+          ...where,
+          ...order,
+          pageNum: page,
+          size: limit,
+          categoryLevelId: this.categoryId,
+          rootCategoryLevelId: this.rootId
+        });
+        this.networkCounts = res;
+        console.log(res, 'resresresresresresresresresresresresresres');
+      },
+      /* 刷新表格 */
+      reload(where) {
+        this.$refs.table.reload({ pageNum: 1, where: where });
+      },
+      // 跳转到详情页
+      details({ id, code, name }) {
+        this.$router.push({
+          path: '/ledgerAssets/equipment/detail',
+          query: {
+            id,
+            code,
+            name
+          }
+        });
+      },
+      // 跳转到编辑
+      handEdit({ id }) {
+        this.$router.push({
+          path: '/ledgerAssets/equipment/edit',
+          query: {
+            id
+          }
+        });
+      },
+      // 跳转到详情页
+      add() {
+        this.$router.push({
+          path: '/ledgerAssets/equipment/edit'
+        });
+      },
+      exportFile() {
+        let params = {
+          ...this.$refs.search.where,
+          exportType: 1,
+          categoryLevelId: this.categoryId,
+          rootCategoryLevelId: this.rootId
+        };
+        // downloadAsset(params, '设备台账导出数据');
+        axios({
+          url: `${API_BASE_URL}/main/asset/page/export`,
+          method: 'post',
+          responseType: 'blob',
+          headers: {
+            Authorization: getToken()
+          },
+          data: params
+        }).then((res) => {
+          download(res.data, '设备台账导出数据');
+        });
+      },
+      handelBOM(row) {
+        let rowData = {
+          categoryId: row.category.id,
+          categoryName: row.categoryName,
+          code: row.code,
+          versions: row.versions,
+          rootPathIdParent: row.category.categoryLevelPathIdParent,
+          isProduct: true,
+          bomType: '1',
+          isTemp: row.isTemp,
+          substanceId:row.id
+
+        };
+        this.$refs.bomDrawer.open(rowData);
+      },
+
+      batchSettings(type) {
+        let ids = this.checkRadioData.map((item) => {
+          return item.id;
+        });
+        this.$refs.batchSetRef.open(type, ids);
+        console.log(this.checkRadioData, 'checkRadioData 123');
+      }
+    },
+    watch: {
+      // 监听类别id变化
+      categoryId() {
+        this.reload();
+      }
+    }
+  };
+</script>
+<style lang="scss" scoped>
+  @media print {
+    #printSection {
+      font-size: 34px;
+      span {
+        font-size: 34px;
+      }
+    }
+  }
+</style>

+ 9 - 5
src/views/ledgerAssets/equipment/detailsPop.vue

@@ -76,7 +76,7 @@
           :responsive="false"
         >
           <div class="ele-border-lighter sys-organization-list">
-            <div>
+            <!-- <div>
               版本号: &nbsp; &nbsp;
               <el-select
                 size="mini"
@@ -94,7 +94,7 @@
                 >
                 </el-option>
               </el-select>
-            </div>
+            </div> -->
 
             <el-tree
               class="treeData"
@@ -143,6 +143,7 @@
                   :attributeData="currentNodeData"
                   :treeId="treeId"
                   :codes="searchObj.code"
+                  :substanceId="substanceId"
                 ></detailedList>
               </el-tab-pane>
             </el-tabs>
@@ -230,7 +231,7 @@
           2: '审核通过',
           3: '审核不通过'
         },
-
+        substanceId: '',
         isWt: false
       };
     },
@@ -245,6 +246,7 @@
       open(row) {
         console.log(row, 'rowrowrowrowrowrowrowrowrow');
         this.searchObj = row;
+        this.substanceId=row.substanceId
 
         if (Object.prototype.hasOwnProperty.call(row, 'isWt') && row.isWt) {
           this.isWt = row.isWt;
@@ -264,7 +266,8 @@
           versions: '',
           categoryId: '',
           isProduct: false,
-          isTemp: 0
+          approvalStatus:2
+          // isTemp: 0
         };
         this.activeName = '属性';
         this.drawer = false;
@@ -340,7 +343,8 @@
         let param = {
           categoryId: this.searchObj.categoryId,
           bomType: this.currentNodeData.bomType,
-          isTemp: this.searchObj.isTemp || 0
+          approvalStatus:2
+          // isTemp: this.searchObj.isTemp || 0
         };
         versionList(param).then((res) => {
           this.versList = res || [];