lyh
2025-06-05 0d27c826c71c323ff605cd27a53bbc5a0c96f752
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
<template>
  <a-modal width="65%" :title="title" :visible="visible" @cancel="visible=false" :maskClosable="false" centered
           @ok="confirmBatchDeleteDocument">
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :md="6" :sm="6">
            <a-form-item label="文件名称">
              <a-input placeholder="请输入文件名称" v-model="queryParam.docName" allow-clear></a-input>
            </a-form-item>
          </a-col>
 
          <a-col :md="8" :sm="8">
            <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="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="ipagination" :loading="loading"
             :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}" @change="handleTableChange"
             :scroll="{y:380}" :size="size" rowKey="docId" style="min-height: 480px">
 
 
      <!-- 字符串超长截取省略号显示-->
      <span slot="docName" slot-scope="text">
                <j-ellipsis :value="text"/>
      </span>
    </a-table>
  </a-modal>
</template>
 
<script>
import { getAction } from '@/api/manage'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import dncApi from '@/api/dnc'
 
export default {
  name: 'DocumentBatchDeleteModal',
  components: {},
  mixins: [JeecgListMixin],
  props: {
    currentDocumentInfo: {
      type: Object
    },
    size: {
      type: String
    }
  },
  data() {
    return {
      disableMixinCreated: true,
      visible: false,
      title: '',
      date: [],
      columns: [
        {
          title: '序号',
          dataIndex: 'rowIndex',
          key: 'rowIndex',
          width: 65,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '文件名称',
          dataIndex: 'docName',
          key: 'docName',
          align: 'center',
          scopedSlots: { customRender: 'docName' },
          width: 300,
          sorter: true
        },
        { title: '设备编号', dataIndex: 'docCode', align: 'center' },
        {
          title: '出库状态',
          dataIndex: 'pullStatus_dictText',
          key: 'pullStatus',
          align: 'center',
          filters: [
            { text: '未出库', value: 1 },
            { text: '已出库', value: 2 }
          ]
        },
        {
          title: '状  态',
          dataIndex: 'docDispatchStatus_dictText',
          key: 'docDispatchStatus',
          align: 'center',
          filters: [
            { text: '编制', value: 1 },
            { text: '校对', value: 2 },
            { text: '批准', value: 3 },
            { text: '试切', value: 4 },
            { text: '定型', value: 5 }
          ]
        },
        { title: '系统指定版本', dataIndex: 'publishVersion', align: 'center', width: 200 },
        {
          title: '创建时间',
          dataIndex: 'createTime',
          align: 'center',
          width: 200,
          sorter: true
        }
      ],
      spinning: false,
      url: {
        list: '/nc/doc/find/page'
      }
    }
  },
  watch: {
    visible: {
      handler(value) {
        if (value) {
          this.resetData()
          this.loadData()
        }
      }
    }
  },
  methods: {
    // 获取当前工序或工步对应文档列表
    loadData() {
      this.dataSource = []
      if (!this.url.list) {
        this.$message.error('请设置url.list属性!')
        return
      }
 
      var params = this.getQueryParams()//查询条件
      if (!params) return false
      const { attributionType, attributionId, param } = this.currentDocumentInfo
      params.attributionType = attributionType
      params.attributionId = attributionId
      params.docClassCode = param
      console.log('params', params)
      this.loading = true
      getAction(this.url.list + `/${this.ipagination.current}/${this.ipagination.pageSize}`, params).then((res) => {
        if (res.success) {
          this.dataSource = res.result.records
          if (res.result.total) {
            this.ipagination.total = res.result.total
          } else {
            this.ipagination.total = 0
          }
        } else this.$message.warning(res.message)
      }).finally(() => {
        this.loading = false
      })
    },
 
    /**
     * 表格分页、排序改变、筛选时触发
     * @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.ipagination = pagination
      this.loadData()
    },
 
    // 时间选择器选择完成后触发
    handleDateChange(value) {
      this.queryParam.startTime = value[0]
      this.queryParam.endTime = value[1]
    },
 
    // 确认批量删除文档
    confirmBatchDeleteDocument() {
      const that = this
      const {
        selectedRowKeys,
        $notification,
        $confirm,
        currentDocumentInfo: { param, attributionId, attributionType }
      } = that
 
      if (selectedRowKeys.length === 0) {
        $notification.warning({
          message: '消息',
          description: '请选择文档'
        })
        return
      }
 
      $confirm({
        title: '提示',
        content: `删除后不可取消,确认删除吗?`,
        okText: '确认',
        cancelText: '取消',
        onOk: () => {
          let hasRequestedSuccessCount = 0
          let hasRequestedCount = 0
          let method
          let queryParam
          selectedRowKeys.forEach(key => {
            if (attributionType !== 4) {
              method = dncApi.deleteDocumentApi
              queryParam = { docId: key,attrType:attributionType,attrId:attributionId }
            } else {
              method = dncApi.deleteDeviceRelativeDocumentApi
              queryParam = { docId: key, attributionId }
            }
            method(queryParam)
              .then(res => {
                if (res.success) {
                  $notification.success({
                    message: '消息',
                    description: res.message
                  })
                  hasRequestedSuccessCount++
                } else {
                  $notification.error({
                    message: '消息',
                    description: res.message
                  })
                }
              })
              .finally(() => {
                hasRequestedCount++
                if (hasRequestedCount === selectedRowKeys.length && hasRequestedSuccessCount > 0) {
                  this.loadData()
                  this.$emit('reloadDocumentListData', { docClassCode: param, attributionId, attributionType })
                }
              })
          })
          that.$destroyAll()
        },
        onCancel: () => {
          that.$destroyAll()
        }
      })
 
 
    },
 
    resetData() {
      this.queryParam = {}
      this.selectedRowKeys = []
    }
  }
}
</script>