lyh
2025-04-17 a95bec239fd7599b4c8766eff35c3d96e813cb25
新增检索电子样板
已添加1个文件
已修改2个文件
520 ■■■■■ 文件已修改
src/views/dnc/base/modules/ProductStructure/Document/NcDocumentSearchModal.vue 507 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/dnc/base/modules/ProductStructure/ProductStructureTree.vue 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/dnc/base/modules/ProductStructure/ProductStructureTreeContextMenu.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/dnc/base/modules/ProductStructure/Document/NcDocumentSearchModal.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,507 @@
<template>
  <a-modal width="75%" :title="title" :visible="visible" @cancel="visible=false" :maskClosable="false" centered
           @ok="handleAssignDocumentToDevice">
    <div class="tabs-container">
      <div style="width: 72%">
        <a-tabs>
          <a-tab-pane tab="文档列表">
            <div class="table-page-search-wrapper">
              <a-form layout="inline" @keyup.enter.native="searchQuery">
                <a-row :gutter="24">
                  <a-col :md="7" :sm="7">
                    <a-form-item label="文件名称">
                      <a-input placeholder="请输入文件名称" v-model="queryParam.docName" allow-clear></a-input>
                    </a-form-item>
                  </a-col>
                  <a-col :md="11" :sm="11">
                    <a-form-item label="上传时间">
                      <a-range-picker v-model="date" value-format="YYYY-MM-DD"
                                      @change="handleDateChange" allow-clear></a-range-picker>
                    </a-form-item>
                  </a-col>
                  <a-col :md="7" :sm="7">
                    <a-form-item label="节点名称">
                      <a-input placeholder="请输入节点名称" v-model="queryParam.treeName" allow-clear></a-input>
                    </a-form-item>
                  </a-col>
                  <a-col :md="7" :sm="7">
                    <a-form-item label="节点代号">
                      <a-input placeholder="请输入节点代号" v-model="queryParam.treeCode" allow-clear></a-input>
                    </a-form-item>
                  </a-col>
                  <a-col :md="7" :sm="7">
                    <a-form-item label="材质">
                      <a-input placeholder="请输入材质" v-model="queryParam.structureType" allow-clear></a-input>
                    </a-form-item>
                  </a-col>
                  <a-col :md="4" :sm="4">
                    <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                  </a-col>
                </a-row>
              </a-form>
            </div>
            <a-table :columns="columns" :data-source="dataSource" bordered :pagination="false" :loading="loading"
                     :rowSelection="{selectedRowKeys: selectedRowKeys,selectedRows:selectionRows, onChange: onSelectChange}"
                     @change="handleTableChange"
                     :scroll="{y:456}" :size="size" rowKey="docId">
            </a-table>
          </a-tab-pane>
        </a-tabs>
      </div>
      <div style="width: 25%">
        <a-tabs>
          <a-tab-pane tab="设备列表">
            <a-spin :spinning="spinning">
              <div style="display: flex;flex-direction: column;">
                <div style="display: flex">
                  <a-input placeholder="输入关键字进行搜索" allowClear v-model="searchInput"
                           @change="handleSearchInputChange"/>
                  <a-button type="primary" @click="isExpandAllTreeNode=!isExpandAllTreeNode" style="margin: 0 8px">
                    å±•å¼€/折叠
                  </a-button>
                </div>
                <!--产品结构树-->
                <div style="overflow:auto;margin-top: 10px;height: 400px">
                  <a-tree blockNode checkable :checkedKeys="checkedKeys" :expandedKeys.sync="expandedKeys"
                          :autoExpandParent="autoExpandParent" @select="handleTreeNodeSelect"
                          :treeData="treeDataSource" @check="handleTreeNodeCheck" @expand="handleTreeNodeExpand">
                    <template slot="title" slot-scope="{ title, parentId, entity, key:treeKey,type}">
                     <span v-if="title.indexOf(searchValue) > -1">{{ title.substr(0, title.indexOf(searchValue)) }}<span
                       class="replaceSearch">{{
                         searchValue
                       }}</span>{{ title.substr(title.indexOf(searchValue) + searchValue.length) }}</span>
                      <span v-else>{{ title }}</span>
                    </template>
                  </a-tree>
                </div>
                <div>
                  <a-form>
                    <a-form-item label="指派原因">
                      <a-textarea v-model="queryParam.applyReason" rows="3" style="resize: none"></a-textarea>
                    </a-form-item>
                  </a-form>
                </div>
              </div>
            </a-spin>
          </a-tab-pane>
        </a-tabs>
      </div>
    </div>
  </a-modal>
</template>
<script>
import { getAction } from '@/api/manage'
import dncApi from '@/api/dnc'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
export default {
  name: 'NcDocumentAssignModal',
  components: {},
  mixins: [JeecgListMixin],
  props: {
    currentDocumentInfo: {
      type: Object
    },
    size: {
      type: String
    }
  },
  data() {
    return {
      disableMixinCreated: true,
      visible: false,
      title: '',
      columns: [
        {
          title: '序号',
          dataIndex: 'rowIndex',
          key: 'rowIndex',
          width: 50,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '节点名称',
          dataIndex: 'nodeName',
          align: 'center',
          width: 80,
          sorter: false
        },
        {
          title: '节点代号',
          dataIndex: 'nodeCode',
          align: 'center',
          width: 80,
          sorter: false
        },
        {
          title: '文件名称',
          dataIndex: 'docName',
          key: 'docName',
          align: 'center',
          width: 200,
          sorter: true
        },
        {
          title: '出库状态',
          dataIndex: 'pullStatus_dictText',
          key: 'pullStatus',
          align: 'center',
          width: 100,
          filters: [
            { text: '未出库', value: 1 },
            { text: '已出库', value: 2 }
          ]
        },
        {
          title: '状  æ€',
          dataIndex: 'docDispatchStatus_dictText',
          key: 'docDispatchStatus',
          align: 'center',
          width: 60,
          filters: [
            { text: '编制', value: 1 },
            { text: '校对', value: 2 },
            { text: '批准', value: 3 },
            { text: '试切', value: 4 },
            { text: '定型', value: 5 }
          ]
        },
        {
          title: '创建时间',
          dataIndex: 'createTime',
          align: 'center',
          width: 150,
          sorter: true
        }
      ],
      searchValue: '',
      searchInput: '',
      spinning: false,
      treeDataSource: [],
      allTreeKeys: [],
      checkedKeys: [],
      expandedKeys: [],
      autoExpandParent: true,
      isExpandAllTreeNode: true,
      date: [],
      url: {
        list: '/nc/product/query'
      }
    }
  },
  watch: {
    visible: {
      handler(value) {
        if (value) {
          this.resetData()
          this.loadData()
          this.getDocumentAssignDeviceTreeByApi()
        }
      }
    },
    isExpandAllTreeNode: {
      handler(value) {
        if (value) this.expandedKeys = this.allTreeKeys
        else this.expandedKeys = []
      }
    }
  },
  created() {
    this.$bus.$on('treeMenuItemMethodTrigger', this.triggerCorrespondingMethod)
  },
  methods: {
    handleSearch() {
      this.visible = true
    },
    // èŽ·å–å½“å‰å¯¹åº”æ–‡æ¡£åˆ—è¡¨
    loadData() {
      this.dataSource = []
      if (!this.url.list) {
        this.$message.error('请设置url.list属性!')
        return
      }
      var params = this.getQueryParams()//查询条件
      if (!params) return false
      params.attributionType = this.currentDocumentInfo.type
      params.attributionId = this.currentDocumentInfo.key
      this.loading = true
      getAction(this.url.list, params).then((res) => {
        if (res.success) this.dataSource = res.result
        else this.$message.warning(res.message)
      }).finally(() => {
        this.loading = false
      })
    },
    // èŽ·å–DNC设备树
    getDocumentAssignDeviceTreeByApi() {
      this.spinning = true
      this.treeDataSource = []
      dncApi.getDeviceTreeDataApi()
        .then(res => {
          if (res.success) {
            this.dataList = []
            this.allTreeKeys = []
            this.treeDataSource = res.result
            this.generateList(this.treeDataSource)
            this.expandedKeys = this.allTreeKeys
          } else {
            this.$message.warn(res.message)
          }
        })
        .finally(() => {
          this.spinning = false
        })
    },
    // æ—¶é—´é€‰æ‹©å™¨é€‰æ‹©å®ŒæˆåŽè§¦å‘
    handleDateChange(value) {
      this.queryParam.startTime = value[0]
      this.queryParam.endTime = value[1]
    },
    /**
     * è¡¨æ ¼åˆ†é¡µã€æŽ’序改变、筛选时触发
     * @param pagination åˆ†é¡µå™¨é€‰é¡¹
     * @param filters ç­›é€‰é€‰é¡¹
     * @param sorter æŽ’序选项
     */
    handleTableChange(pagination, filters, sorter) {
      if (sorter.order) {
        this.isorter.column = sorter.field
        this.isorter.order = sorter.order === 'ascend' ? 'asc' : 'desc'
      } else {
        this.isorter.column = 'createTime'
        this.isorter.order = 'desc'
      }
      for (let key in filters) {
        this.filters[key] = filters[key].join(',')
      }
      this.loadData()
    },
    // æŒ‡æ´¾åˆ°è®¾å¤‡çª—口点击确定指派设备后触发
    handleAssignDocumentToDevice() {
      const {
        checkedKeys,
        selectedRowKeys,
        selectionRows,
        dataList,
        $confirm,
        $notification,
        currentDocumentInfo,
        queryParam: { applyReason },
        $destroyAll,
        $bus
      } = this
      const { attributionId, attributionType } = currentDocumentInfo
      const paramsArray = []
      // è¿‡æ»¤è½¦é—´key仅放入设备key
      const treeCheckedDeviceKeys = []
      checkedKeys.forEach(checkedKey => {
        const device = dataList.find(item => item.key === checkedKey && item.type === 2)
        if (device) treeCheckedDeviceKeys.push(device.key)
      })
      if (treeCheckedDeviceKeys.length === 0 || selectedRowKeys.length === 0) {
        $notification.warning({
          message: '消息',
          description: '请选择设备或文档'
        })
        return
      }
      $confirm({
        title: '提示',
        content: `确认提交吗?`,
        okText: '确认',
        cancelText: '取消',
        onOk: () => {
          // åŒé‡å¾ªçŽ¯ç¡®å®šæ¯ä¸€ç»„è®¾å¤‡ä¸Žæ–‡æ¡£çš„å‚æ•°
          treeCheckedDeviceKeys.forEach(deviceId => {
            selectionRows.forEach(({ docId, publishFileId ,attributionId,attributionType}) => {
              paramsArray.push({
                docId,
                deviceId,
                fileId: publishFileId,
                attributionId,
                attributionType,
                applyReason
              })
            })
          })
          paramsArray.forEach(item => {
            dncApi.assignDocumentToDeviceApi(item)
              .then(res => {
                if (res.success) {
                  $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
                })
              })
              .finally(() => {
                $destroyAll()
              })
          })
        },
        onCancel: () => {
          $destroyAll()
        }
      })
    },
    /* è¾“入查询内容变化时触发 */
    handleSearchInputChange() {
      let search = this.searchInput
      console.log('data', this.dataList)
      console.log('search', search)
      let expandedKeys = this.dataList
        .map(item => {
          if (item.title != null) {
            if (item.title.indexOf(search) > -1) {
              return this.getParentKey(item.key, this.treeDataSource)
            }
            return null
          }
        })
        .filter((item, i, self) => item && self.indexOf(item) === i)
      Object.assign(this, {
        expandedKeys,
        searchValue: search,
        autoExpandParent: true
      })
    },
    /**
     * æ ‘节点展开合并时触发
     * @param expandedKeys å±•开项key
     */
    handleTreeNodeExpand(expandedKeys) {
      this.expandedKeys = expandedKeys
      this.autoExpandParent = false
    },
    /**
     * æ ‘节点复选框选中时触发
     * @param selectedKeys é€‰ä¸­èŠ‚ç‚¹key
     * @param {node} node èŠ‚ç‚¹å¯¹è±¡
     */
    handleTreeNodeCheck(checkedKeys, { node }) {
      let record = node.dataRef
      this.checkedKeys = checkedKeys
    },
    /**
     * æ ‘节点选中时触发(模拟树节点复选框选中时的效果)
     * @param selectedKeys é€‰ä¸­èŠ‚ç‚¹key
     * @param {node} node èŠ‚ç‚¹å¯¹è±¡
     */
    handleTreeNodeSelect(selectedKeys, { node }) {
      node.$el.childNodes[1].click()
    },
    /**
     * é€’归获得输入项的父级key
     * @param key å­é¡¹key
     * @param tree å­é¡¹
     */
    getParentKey(key, tree) {
      let parentKey
      for (let i = 0; i < tree.length; i++) {
        const node = tree[i]
        if (node.children) {
          if (node.children.some(item => item.key === key)) {
            parentKey = node.key
            console.log('parentKey', parentKey)
          } else if (
            this.getParentKey(key, node.children)) {
            parentKey = this.getParentKey(key, node.children)
          }
        }
      }
      return parentKey
    },
    /**
     * é€’归获得所有树节点key
     * @param data è®¾å¤‡æ ‘数据
     */
    generateList(data) {
      for (let i = 0; i < data.length; i++) {
        const node = data[i]
        const key = node.key
        const title = node.title
        const type = node.type
        this.dataList.push({ key, title, type })
        this.allTreeKeys.push(key)
        if (node.children) this.generateList(node.children)
      }
    },
    resetData() {
      this.searchInput = ''
      this.expandedKeys = []
      this.selectedRowKeys = []
      this.selectionRows = {}
      this.checkedKeys = []
      this.filters = {}
      this.isorter = Object.assign({}, this.defaultSorter)
    },
    triggerCorrespondingMethod({ methodName, modalTitle }) {
      if (this[methodName]) {
        this[methodName]()
        this.title = modalTitle
      }
    }
  }
}
</script>
<style scoped lang="less">
/deep/ .ant-modal {
  .tabs-container {
    display: flex;
    justify-content: space-between;
    .replaceSearch {
      color: #40a9ff;
      font-weight: bold;
      background-color: rgb(204, 204, 204);
    }
  }
}
::-webkit-scrollbar {
  width: 8px;
}
</style>
src/views/dnc/base/modules/ProductStructure/ProductStructureTree.vue
@@ -61,6 +61,8 @@
    <ProcessStepModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
    <!--权限配置弹窗-->
    <AssignPermissionModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
    <!--检索电子模板弹窗-->
    <NcDocumentSearchModal :currentDocumentInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
    <!--产品结构树基本右键菜单(空白处触发)-->
    <ProductStructureBaseContextMenu ref="baseContextmenuRef"/>
  </a-card>
@@ -78,8 +80,8 @@
import ProcessStepModal from './ProcessStep/ProcessStepModal'
import AssignPermissionModal from './Permission/AssignPermissionModal'
import DeviceCustomTypeModal from '@views/dnc/base/modules/ProductStructure/DeviceCustomType/DeviceCustomTypeModal.vue'
import ProductStructureBaseContextMenu
  from '@views/dnc/base/modules/ProductStructure/ProductStructureBaseContextMenu.vue'
import ProductStructureBaseContextMenu from '@views/dnc/base/modules/ProductStructure/ProductStructureBaseContextMenu.vue'
import NcDocumentSearchModal from '@views/dnc/base/modules/ProductStructure/Document/NcDocumentSearchModal.vue'
export default {
  name: 'ProductStructureTree',
@@ -93,7 +95,8 @@
    PartModal,
    ComponentModal,
    ProductModal,
    ProductStructureTreeContextMenu
    ProductStructureTreeContextMenu,
    NcDocumentSearchModal
  },
  data() {
    return {
src/views/dnc/base/modules/ProductStructure/ProductStructureTreeContextMenu.vue
@@ -40,6 +40,7 @@
          { label: '编辑产品信息', code: 'product_edit', icon: 'edit', isCommonMethod: false },
          // {  label: '导出文档', code: 'product_export', icon: 'export', isCommonMethod: true },
          { label: '导入其他文档', code: 'product_import', icon: 'import', isCommonMethod: true },
          { label: '检索电子样板', code: 'product_search', icon: 'search', isCommonMethod: true },
          { label: '删除', code: 'product_delete', icon: 'delete', isCommonMethod: true },
          { label: '权限配置', code: 'public_assign_permission', icon: 'idcard', isCommonMethod: true }
        ],
@@ -51,6 +52,7 @@
          { label: '编辑部件信息', code: 'component_edit', icon: 'edit', isCommonMethod: false },
          // {  label: '导出文档', code: 'component_export', icon: 'export', isCommonMethod: true },
          { label: '导入其他文档', code: 'component_import', icon: 'import', isCommonMethod: true },
          { label: '检索电子样板', code: 'component_search', icon: 'search', isCommonMethod: true },
          { label: '删除', code: 'component_delete', icon: 'delete', isCommonMethod: true },
          { label: '权限配置', code: 'public_assign_permission', icon: 'idcard', isCommonMethod: true }
        ],
@@ -62,6 +64,7 @@
          { label: '编辑零件信息', code: 'parts_edit', icon: 'edit', isCommonMethod: false },
          // {  label: '导出文档', code: 'parts_export', icon: 'export', isCommonMethod: true },
          { label: '导入其他文档', code: 'parts_import', icon: 'import', isCommonMethod: true },
          { label: '检索电子样板', code: 'parts_search', icon: 'search', isCommonMethod: true },
          { label: '删除', code: 'parts_delete', icon: 'delete', isCommonMethod: true },
          { label: '权限配置', code: 'public_assign_permission', icon: 'idcard', isCommonMethod: true }
        ],
@@ -71,6 +74,7 @@
          { label: '创建工序', code: 'version_add_child', icon: 'plus', isCommonMethod: false },
          { label: '编辑工艺规程版本信息', code: 'version_edit', icon: 'edit', isCommonMethod: false },
          { label: '导入其他文档', code: 'version_import', icon: 'import', isCommonMethod: true },
          { label: '检索电子样板', code: 'version_search', icon: 'search', isCommonMethod: true },
          { label: '删除', code: 'version_delete', icon: 'delete', isCommonMethod: true },
          { label: '权限配置', code: 'public_assign_permission', icon: 'idcard', isCommonMethod: true }
        ],