zhaowei
2025-01-20 5ffe205b81d80bff5f64c9799f54d4309b86369d
产品结构树页面新增NC程序指派到设备功能
已修改4个文件
135 ■■■■ 文件已修改
src/api/dnc.js 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/dnc/base/modules/ProductStructure/Document/NcDocumentAssignModal.vue 92 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/dnc/base/modules/ProductStructure/Document/UseNcDocumentEquipmentTableList.vue 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/dnc/base/modules/ProductStructure/ProductStructureMainBottom.vue 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/dnc.js
@@ -23,6 +23,8 @@
  },
  // 获取指派到设备中的设备树
  getDocumentAssignDeviceTreeApi: ({ attributionType, attributionId }) => getAction(`/nc/device/load/depart/tree/${attributionType}/${attributionId}`),
  // 指派文档到设备
  assignDocumentToDeviceApi: params => postAction('/nc/activit/assign/file/apply', params),
  // 下载文档
  downloadDocumentApi: ({ id, docName }) => downloadFile(`/nc/doc/download/${id}`, docName),
  // 文档出库
src/views/dnc/base/modules/ProductStructure/Document/NcDocumentAssignModal.vue
@@ -45,15 +45,9 @@
                <div style="display: flex">
                  <a-input placeholder="输入关键字进行搜索" allowClear v-model="searchInput"
                           @change="handleSearchInputChange"/>
                  <a-dropdown :trigger="['click']" placement="bottomCenter" style="margin: 0 8px">
                    <a-menu slot="overlay">
                      <a-menu-item key="1" @click="expandedKeys = allTreeKeys">展开所有</a-menu-item>
                      <a-menu-item key="2" @click="expandedKeys = []">合并所有</a-menu-item>
                    </a-menu>
                    <a-button>
                      <a-icon type="bars"/>
                    </a-button>
                  </a-dropdown>
                  <a-button type="primary" @click="isExpandAllTreeNode=!isExpandAllTreeNode" style="margin: 0 8px">
                    展开/折叠
                  </a-button>
                </div>
                <!--产品结构树-->
@@ -89,11 +83,10 @@
  import { getAction } from '@/api/manage'
  import dncApi from '@/api/dnc'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import ATextarea from 'ant-design-vue/es/input/TextArea'
  export default {
    name: 'NcDocumentAssignModal',
    components: { ATextarea },
    components: {},
    mixins: [JeecgListMixin],
    props: {
      currentDocumentInfo: {
@@ -133,6 +126,7 @@
        checkedKeys: [],
        expandedKeys: [],
        autoExpandParent: true,
        isExpandAllTreeNode: false,
        url: {
          list: '/nc/doc/find/list'
        }
@@ -146,6 +140,12 @@
            this.loadData()
            this.getDocumentAssignDeviceTreeByApi()
          }
        }
      },
      isExpandAllTreeNode: {
        handler(value) {
          if (value) this.expandedKeys = this.allTreeKeys
          else this.expandedKeys = []
        }
      }
    },
@@ -161,7 +161,6 @@
          return false
        }
        const { attributionType, attributionId, param } = this.currentDocumentInfo
        console.log('currentDocumentInfo', this.currentDocumentInfo)
        params.attributionType = attributionType
        params.attributionId = attributionId
        params.docClassCode = param
@@ -195,15 +194,71 @@
      },
      handleAssignDocumentToDevice() {
        const param = {}
        console.log('table', this.selectedRowKeys)
        const { checkedKeys, selectedRowKeys, dataList, $confirm, $notification, currentDocumentInfo, queryParam: { applyReason }, $set } = this
        const { publishFileId, attributionId } = currentDocumentInfo
        const paramsArray = []
        // 过滤分组Id仅放入设备Id
        const treeCheckedDeviceKeys = []
        this.checkedKeys.forEach(checkedKey => {
          const deviceId = this.dataList.find(item => item.key === checkedKey && item.type === 2)
        checkedKeys.forEach(checkedKey => {
          const deviceId = dataList.find(item => item.key === checkedKey && item.type === 2)
          if (deviceId) treeCheckedDeviceKeys.push(deviceId.key)
        })
        console.log('treeCheckedDeviceKeys', treeCheckedDeviceKeys)
        if (treeCheckedDeviceKeys.length === 0 || selectedRowKeys.length === 0) {
          $notification.warning({
            message: '消息',
            description: '请选择设备或文档'
          })
          return
        }
        $confirm({
          title: '提示',
          content: `确认提交吗?`,
          okText: '确认',
          cancelText: '取消',
          onOk: () => {
            treeCheckedDeviceKeys.forEach(deviceId => {
              selectedRowKeys.forEach(docId => {
                paramsArray.push({
                  docId,
                  deviceId,
                  fileId: publishFileId,
                  processId: attributionId,
                  applyReason
                })
              })
            })
            paramsArray.forEach(item => {
              dncApi.assignDocumentToDeviceApi(item)
                .then(res => {
                  if (res.success) {
                    this.$bus.$emit('reloadMainBottomTableData', 'useDocumentEquipment')
                    $notification.success({
                      message: '消息',
                      description: res.message
                    })
                  } else {
                    $notification.error({
                      message: '消息',
                      description: res.message
                    })
                  }
                })
                .catch(err => {
                  $notification.error({
                    message: '消息',
                    description: err.message
                  })
                })
            })
            console.log('paramsArray', paramsArray)
          }
        })
        // console.log('table', this.selectedRowKeys)
        // console.log('treeCheckedDeviceKeys', treeCheckedDeviceKeys)
        // console.log('currentDocumentInfo', this.currentDocumentInfo)
      },
      /* 输入查询内容变化时触发 */
@@ -311,4 +366,7 @@
  }
  ::-webkit-scrollbar {
    width: 8px;
  }
</style>
src/views/dnc/base/modules/ProductStructure/Document/UseNcDocumentEquipmentTableList.vue
@@ -1,18 +1,28 @@
<template>
  <a-table :columns="columns" :data-source="dataSource" bordered :pagination="false">
  <a-table :columns="columns" :data-source="dataSource" bordered :pagination="false" :size="size" rowKey="deviceId">
  </a-table>
</template>
<script>
  import { getAction } from '@/api/manage'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  export default {
    name: 'UseNcDocumentEquipmentTableList',
    components: {},
    mixins: [JeecgListMixin],
    props: {
      currentDocumentInfo: {
        type: Object
      },
      size: {
        type: String
      }
    },
    data() {
      return {
        disableMixinCreated: true,
        columns: [
          {
            title: '序号',
@@ -32,11 +42,33 @@
          { title: '控制系统', dataIndex: 'controlSystem', align: 'center' }
        ],
        url: {
          list: ''
          list: '/doc/relative/get/device'
        }
      }
    },
    methods: {}
    methods: {
      loadData() {
        this.dataSource = []
        if (!this.url.list) {
          this.$message.error('请设置url.list属性!')
          return
        }
        var params = this.getQueryParams()//查询条件
        if (!params) {
          return false
        }
        this.loading = true
        getAction(this.url.list + `/${this.currentDocumentInfo.docId}`, params).then((res) => {
          if (res.success) {
            this.dataSource = res.list
          } else {
            this.$message.warning(res.message)
          }
        }).finally(() => {
          this.loading = false
        })
      }
    }
  }
</script>
src/views/dnc/base/modules/ProductStructure/ProductStructureMainBottom.vue
@@ -36,7 +36,8 @@
      </a-tab-pane>
      <a-tab-pane :key="4" tab="使用设备" v-if="currentLevelInfo.attributionType===5">
        <UseDocumentEquipmentTableList ref="useDocumentEquipmentTableRef"/>
        <UseDocumentEquipmentTableList ref="useDocumentEquipmentTableRef" :currentDocumentInfo="currentLevelInfo"
                                       :size="containerSize"/>
      </a-tab-pane>
    </template>
  </a-tabs>