lyh
2025-06-16 e48436b9c5dd3f0365f77339f84b37eea95b56e2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<template>
  <div>
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :md="5" :sm="5">
            <a-form-item label="刀具编号">
              <a-input placeholder="请输入刀具编号" v-model="queryParam.cutterCode" allow-clear/>
            </a-form-item>
          </a-col>
 
          <a-col :md="5" :sm="5">
            <a-form-item label="刀具名称">
              <a-input placeholder="请输入刀具名称" v-model="queryParam.cutterName" allow-clear/>
            </a-form-item>
          </a-col>
 
          <a-col :md="4" :sm="4">
            <a-space>
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="handleAdd" icon="plus" v-has="'cutter_add'">新增</a-button>
              <a-button type="primary" @click="handleSend()" icon="export">发送刀具系统</a-button>
            </a-space>
          </a-col>
        </a-row>
      </a-form>
    </div>
 
    <a-table :columns="columns" :data-source="dataSource" bordered :pagination="ipagination" :size="size" rowKey="id"
             @change="handleTableChange" :scroll="{y:189}">
      <template slot="action" slot-scope="text, record">
 
        <a @click="handleChoose(record)">选择刀具</a>
 
        <a-divider type="vertical"/>
 
        <a-dropdown>
          <a class="ant-dropdown-link">
            更多
            <a-icon type="down"/>
          </a>
          <a-menu slot="overlay">
            <a-menu-item>
              <a href="javascript:;" @click="handleDetail(record)">详情</a>
            </a-menu-item>
 
            <a-menu-item>
              <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                <a>删除</a>
              </a-popconfirm>
            </a-menu-item>
          </a-menu>
        </a-dropdown>
      </template>
    </a-table>
 
    <CutterModal ref="cutterModalRef" :currentTreeNodeInfo="currentLevelInfo" @submitSuccess="loadData"/>
 
    <DncToolsSelectModal ref="dncToolsSelectModal" @submitSuccess="loadData"/>
  </div>
</template>
 
<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import CutterModal from '@views/dnc/base/modules/ProductStructure/Cutter/CutterModal.vue'
import DncToolsSelectModal from '@views/tms/modules/baseTools/DncToolsSelectModal.vue'
import { getAction, httpAction } from '@api/manage'
import dncApi from '@api/dnc'
 
export default {
  name: 'CutterTableList',
  components: { DncToolsSelectModal, CutterModal },
  mixins: [JeecgListMixin],
  props: {
    currentLevelInfo: {
      type: Object
    },
    size: {
      type: String
    }
  },
  data() {
    return {
      disableMixinCreated: true,
      columns: [
        {
          title: '序号',
          dataIndex: 'rowIndex',
          key: 'rowIndex',
          width: 65,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        { title: '刀具编号', dataIndex: 'cutterCode', width: 200, align: 'center' },
        { title: '刀具名称', dataIndex: 'cutterName', width: 100, align: 'center' },
        { title: '刀具简称', dataIndex: 'cutterType', width: 80, align: 'center' },
        { title: '刀具规格', dataIndex: 'cutterSpec', align: 'center' },
        { title: '额定寿命', dataIndex: 'lifetime', width: 150, align: 'center' },
        { title: '刀位', dataIndex: 'cutterSpacing', width: 50, align: 'center' },
        { title: '刀具数量', dataIndex: 'quantity', width: 80, align: 'center' },
        { title: '描述', dataIndex: 'description', width: 200, align: 'center' },
        { title: '操作', dataIndex: 'action', scopedSlots: { customRender: 'action' }, align: 'center', width: 150 }
      ],
      url: {
        list: '/nc/cutter/getByBusinessId',
        delete: '/nc/cutter/delete',
        exportXlsUrl: '/nc/cutter/exportXls',
        importExcelUrl: '/nc/cutter/importExcel',
        sendCutterUrl: '/nc/cutter/sendCutterUrl',
      }
    }
  },
  computed: {
    importExcelUrl: function() {
      return `${window._CONFIG['domianURL']}${this.url.importExcelUrl}`
    }
  },
  methods: {
    setQueryParamAndLoadData(pageNo = 1) {
      if (this.currentLevelInfo.classificationId_dictText==='nc'){
        const {docId,attributionType,attributionId} = this.currentLevelInfo
        this.queryParam = Object.assign({}, { docId:docId,attributionType:attributionType,attributionId:attributionId })
      }
      if (this.currentLevelInfo.deviceManagementId !== null && this.currentLevelInfo.deviceManagementId !== undefined){
        const {attributionType,id} = this.currentLevelInfo
        this.queryParam = Object.assign({}, {attributionType:attributionType,attributionId:id })
      }
      if (this.currentLevelInfo.id !== null && this.currentLevelInfo.type !== null && this.currentLevelInfo.type !== undefined && this.currentLevelInfo.id !== undefined){
        const { id, type } = this.currentLevelInfo
        this.queryParam = Object.assign({}, { attributionId: id, attributionType: type })
      }
      this.loadData(pageNo)
    },
    searchQuery(pageNo = 1) {
      if (this.currentLevelInfo.classificationId_dictText==='nc'){
        const {docId,attributionType,attributionId} = this.currentLevelInfo
        this.queryParam = Object.assign({}, { docId:docId,attributionType:attributionType,attributionId:attributionId })
      }
      if (this.currentLevelInfo.deviceManagementId !== null && this.currentLevelInfo.deviceManagementId !== undefined){
        const {attributionType,id} = this.currentLevelInfo
        this.queryParam = Object.assign({}, {attributionType:attributionType,attributionId:id })
      }
      if (this.currentLevelInfo.id !== null && this.currentLevelInfo.type !== null && this.currentLevelInfo.type !== undefined && this.currentLevelInfo.id !== undefined){
        const { id, type } = this.currentLevelInfo
        this.queryParam = Object.assign({}, { attributionId: id, attributionType: type })
      }
      this.loadData(pageNo)
    },
 
    handleAdd() {
      if (!this.$refs.cutterModalRef) return
      this.$refs.cutterModalRef.title = '添加刀具'
      this.$refs.cutterModalRef.disableSubmit = false
      this.$refs.cutterModalRef.handleCutterAdd()
    },
 
    /**
     * 编辑表格行信息
     * @param record 表格行信息
     */
    handleEdit(record) {
      if (!this.$refs.cutterModalRef) return
      this.$refs.cutterModalRef.title = '编辑刀具信息'
      this.$refs.cutterModalRef.disableSubmit = false
      this.$refs.cutterModalRef.handleCutterEdit(record)
    },
 
    /**
     * 查看表格完整行信息
     * @param record 表格行信息
     */
    handleDetail: function(record) {
      if (!this.$refs.cutterModalRef) return
      this.$refs.cutterModalRef.title = '刀具详情'
      this.$refs.cutterModalRef.disableSubmit = true
      this.$refs.cutterModalRef.handleCutterEdit(record)
    },
    /**
     * 选择刀具
     */
    handleChoose(record){
      if (record.cutterName.match(/\d+(\.\d+)?/g) !== null) {
        record.cutterName = record.cutterName.match(/\d+(\.\d+)?/g)[0]
      }
      const param = {
        aliasLabel: record.cutterType,
        diameter: record.cutterName,
        cutterId: record.id
      }
      this.$refs.dncToolsSelectModal.open(param)
      this.$refs.dncToolsSelectModal.title = '选择刀具'
    },
    /**
     * 发送刀具系统
     */
    handleSend(){
      const that = this
      const { docId,attributionId, attributionType } = this.currentLevelInfo
      that.$confirm({
        title: '提示',
        content: `确认发送刀具系统吗?`,
        okText: '确认',
        cancelText: '取消',
        onOk: () => {
          dncApi.sendToolsApi({ docId, attributionId, attributionType })
            .then(res => {
              if (res.success) {
                that.$notification.success({
                  message: '消息',
                  description: res.message
                })
              } else {
                that.$notification.error({
                  message: '消息',
                  description: res.message
                })
              }
            })
            .catch(err => {
              that.$notification.error({
                message: '消息',
                description: err.message
              })
            })
            .finally(() => {
              that.$destroyAll()
            })
        },
        onCancel: () => {
          that.$destroyAll()
        }
      })
    }
  }
}
</script>