bug
jiangping
2023-12-06 1f4e7d0f73a73e7350cf5a1df279d5f30904c5d5
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
<template>
  <TableLayout v-permissions="['ext:userdeviceext:query']">
    <!-- 搜索表单 -->
    <el-form ref="searchForm" slot="search-form" :model="searchForm" label-suffix=":" label-width="100px" inline>
      <el-form-item label="设备名称" prop="deviceId">
        <el-select v-model="searchForm.deviceId" filterable clearable placeholder="全部">
          <el-option
            v-for="item in device"
            :key="item.id"
            :label="'【' + item.code+' 】'+ item.name"
            :value="item.id">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="所属工序" prop="dmodelProcedureId">
        <el-select v-model="searchForm.dmodelProcedureId" filterable clearable placeholder="全部">
          <el-option
            v-for="item in productes"
            :key="item.id"
            :label="item.name"
            :value="item.id">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="所属员工" prop="companyUserId">
        <el-select v-model="searchForm.companyUserId" clearable filterable placeholder="全部">
          <el-option
            v-for="item in user"
            :key="item.id"
            :label="item.name + '-' + item.dmodel.name + '-' + item.phone"
            :value="item.id">
          </el-option>
        </el-select>
      </el-form-item>
      <section>
        <el-button type="primary" @click="search">搜索</el-button>
        <el-button @click="reset">重置</el-button>
      </section>
    </el-form>
    <!-- 表格和分页 -->
    <template v-slot:table-wrap>
      <ul class="toolbar" v-permissions="['ext:userdeviceext:create', 'ext:userdeviceext:delete']">
        <li><el-button type="primary" @click="$refs.operaUserDeviceExtWindow.open('新建')" v-permissions="['ext:userdeviceext:create']">新增</el-button></li>
        <li><el-button type="danger" plain @click="deleteByIdInBatch" v-permissions="['ext:userdeviceext:delete']">删除</el-button></li>
      </ul>
      <el-table
        v-loading="isWorking.search"
        :data="tableData.list"
        stripe
        border
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" width="55"></el-table-column>
        <el-table-column prop="brand" label="设备编号" min-width="100px">
          <template slot-scope="{row}">
            {{ row.dmodel.code }}
          </template>
        </el-table-column>
        <el-table-column prop="name" label="设备名称" min-width="100px">
          <template slot-scope="{row}">
            {{ row.dmodel.name }}
          </template>
        </el-table-column>
        <el-table-column prop="model" label="设备型号" min-width="100px">
          <template slot-scope="{row}">
            {{ row.dmodel.model }}
          </template>
        </el-table-column>
        <el-table-column prop="procedureId" label="所属工序" min-width="100px">
          <template slot-scope="{row}">
            {{ procedureIdToStr(row.dmodel.procedureId) }}
          </template>
        </el-table-column>
        <el-table-column prop="createUser" label="关联员工" min-width="100px">
          <template slot-scope="{row}">
            {{ row.umodel.name + '-' + row.tmodel.name }}
          </template>
        </el-table-column>
        <el-table-column prop="createTime" label="创建时间" min-width="100px"></el-table-column>
        <!-- <el-table-column
          v-if="containPermissions(['ext:barcodesgext:update', 'ext:barcodesgext:delete'])"
          label="操作"
          min-width="120"
          fixed="right"
        > -->
        <el-table-column
          v-if="containPermissions(['ext:userdeviceext:delete'])"
          label="操作"
          min-width="80px"
          fixed="right"
        >
           <template slot-scope="{row}">
            <span v-permissions="['ext:userdeviceext:delete']">
              <el-button type="text" @click="deleteById(row)">删除</el-button>
            </span>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        @size-change="handleSizeChange"
        @current-change="handlePageChange"
        :pagination="tableData.pagination"
      >
      </pagination>
    </template>
    <!-- 新建/修改 -->
    <OperaUserDeviceExtWindow ref="operaUserDeviceExtWindow" @success="refresh"/>
  </TableLayout>
</template>
 
<script>
import BaseTable from '@/components/base/BaseTable'
import TableLayout from '@/layouts/TableLayout'
import Pagination from '@/components/common/Pagination'
import OperaUserDeviceExtWindow from '@/components/ext/OperaUserDeviceExtWindow'
import { getDeviceByCondition } from '@/api/ext/deviceExt'
import { productesGroup } from '@/api/ext/proceduresExt'
import { companyUserExtAllUser as getUserDevice } from '@/api/ext/companyUserExt'
// import { getUserDevice } from '@/api/ext/userDeviceExt'
export default {
  name: 'BarcodeSgExt',
  extends: BaseTable,
  components: { TableLayout, Pagination, OperaUserDeviceExtWindow },
  data () {
    return {
      // 搜索
      searchForm: {
        deviceId: null,
        dmodelProcedureId: null,
        companyUserId: null
      },
      device: [],
      productes: [],
      user: []
    }
  },
  provide() {
    return {
      device: () => this.device,
      user: () => this.user
    }
  },
  created () {
    this.config({
      module: '设备绑定',
      api: '/ext/userDeviceExt',
      'field.id': 'id',
      'field.main': 'name',
      sorts: [{ direction: 'DESC', property: 'CREATE_TIME' }]
    })
    this.search()
    this.getUser()
  },
  activated() {
    getDeviceByCondition({})
      .then(res => {
        this.device = res
      })
      .catch(err => {
        console.log(err)
      })
      productesGroup({})
      .then(res => {
        this.productes = res
      })
      .catch(err => {
        console.log(err)
      })
  },
  methods: {
    getUser () {
      getUserDevice({ departmentId: this.$store.state.userInfo.curComDepartment.id })
        .then(res => {
          this.user = res
        })
        .catch(err => {
          console.log(err)
        })
    },
    procedureIdToStr (id) {
      for (const item of this.productes) {
        if (item.id === id) {
          return item.name
        }
      }
    },
    deleteById (row) {
      this.$confirm('是否删除将该条设备绑定信息?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.isWorking.delete = true
        this.api.deleteById(row[this.configData['field.id']])
          .then(() => {
            this.__afterDelete()
          })
          .catch(e => {
            this.$tip.apiFailed(e)
          })
          .finally(() => {
            this.isWorking.delete = false
          })
      }).catch(() => {})
    },
    refresh () {
      this.getUser()
      this.handlePageChange()
    }
  }
}
</script>