Houjie
2025-05-23 6232ac30ca4f54e28ddeccdf5aca03734d02aada
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
<template>
  <!--支持全屏缩放-->
  <j-modal
    :visible="visible"
    :width="1200"
    :title="title"
    switchFullscreen
    @ok="handleSubmit"
    @cancel="close"
    style="top: 50px"
    cancelText="关闭"
  >
    <a-card :bordered="false">
      <div class="table-page-search-wrapper">
        <a-form layout="inline" @keyup.enter.native="searchQuery">
          <a-row :gutter="24">
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="工具编码">
                <a-input placeholder="请输入工具编码,支持模糊查询" v-model="queryParam.toolCode"></a-input>
              </a-form-item>
            </a-col>
            <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
            <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
          </a-row>
        </a-form>
      </div>
      <!--出库单列表-->
      <a-table
        ref="table"
        size="middle"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :rowSelection="rowSelection"
        :loading="loading"
        @change="handleTableChange"
      >
      </a-table>
    </a-card>
  </j-modal>
</template>
 
<script>
import { filterObj } from '@/utils/util'
import { getAction } from '@api/manage'
 
export default {
  name: 'JSelectLossboundToolModal',
  components: {},
  props: {},
  data() {
    return {
      title: '选择出库工具',
      queryParam: {},
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: (_, __, index) => parseInt(index) + 1
        },
        {
          title: '工具编码',
          align: 'center',
          dataIndex: 'toolCode'
        },
        {
          title: '中文名称',
          align: 'center',
          dataIndex: 'chineseName'
        },
        {
          title: '型号/图号',
          align: 'center',
          dataIndex: 'toolModel'
        }
      ],
      selectedRowKeys: [],
      oldSelectRow: [],
      scrollTrigger: { x: 1500, y: 500 },
      dataSource: [],
      selectionRows: [],
      ipagination: {
        current: 1,
        pageSize: 10,
        pageSizeOptions: ['5', '10', '20'],
        showTotal: (total, range) => {
          return range[0] + '-' + range[1] + ' 共' + total + '条'
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0,
      },
      isorter: {
        column: 'toolCode',
        order: 'asc',
      },
      departTree: [],
      visible: false,
      loading: false,
      prepareKnifeDetailList:[],
      url: {
        list: '/tms/baseTools/listWithLedgerAndConfig'
      },
    }
  },
  computed: {
    rowSelection() {
      return {
        type: 'checkbox',
        onChange: (selectedRowKeys, selectedRows) => {
          this.selectedRowKeys = selectedRowKeys
          this.onSelectChange(selectedRows)
        },
        getCheckboxProps: (record) => ({
          props: {
            disabled: record.disabled,
          },
        }),
      }
    },
  },
  watch: {
  },
  created() {
  },
  methods: {
    async loadData(arg) {
      if (arg === 1) {
        this.ipagination.current = 1
      }
      this.loading = true
      let params = this.getQueryParams() //查询条件
      console.log(params)
      await getAction(this.url.list, params).then((res) => {
        if (res.success) {
          this.dataSource = res.result.records
          this.ipagination.total = res.result.total
        }
        if (res.code === 510) {
          this.$message.warning(res.message)
        }
        this.loading = false
      })
    },
    showModal(oldSelectRow) {
      this.oldSelectRow = oldSelectRow
      this.visible = true
      this.queryParam.status = '1'
      this.queryParam.excludeIds = oldSelectRow
      this.loadData(1)
    },
    getQueryParams() {
      let param = Object.assign({}, this.queryParam, this.isorter)
      param.field = this.getQueryField()
      param.pageNo = this.ipagination.current
      param.pageSize = this.ipagination.pageSize
      return filterObj(param)
    },
    //查询条件处理
    getQueryField() {
      let fields = ['id'];
      for (let a = 0; a < this.columns.length; a++) {
        fields.push(this.columns[a].dataIndex);
      }
      return fields.join(',');
    },
    searchReset() {
      this.queryParam = {}
      this.loadData(1)
    },
    close() {
      this.queryParam = {}
      // this.searchReset(0)
      this.selectedRowKeys = []
      this.selectionRows = []
      this.visible = false
    },
    handleTableChange(pagination, filters, sorter) {
      if (Object.keys(sorter).length > 0) {
        this.isorter.column = sorter.field
        this.isorter.order = 'ascend' === sorter.order ? 'asc' : 'desc'
      }
      this.ipagination = pagination
      this.loadData()
    },
    handleSubmit() {
      if (this.selectionRows.length > 0) {
        this.$bus.$emit('selectionRows', this.selectionRows)
        // this.searchReset(0)
        this.close()
      } else {
        this.$message.warning('请至少选择一条数据')
      }
    },
    onSelectChange(selectionRows) {
      this.selectionRows = selectionRows
    },
    searchQuery() {
      this.loadData(1)
    },
  },
}
</script>
 
<style scoped>
.ant-table-tbody .ant-table-row td {
  padding-top: 10px;
  padding-bottom: 10px;
}
 
#components-layout-demo-custom-trigger .trigger {
  font-size: 18px;
  line-height: 64px;
  padding: 0 24px;
  cursor: pointer;
  transition: color 0.3s;
}
</style>