瀏覽代碼

新增所有设备组件

余思翰 11 月之前
父節點
當前提交
bb2ad8af85
共有 1 個檔案被更改,包括 210 行新增0 行删除
  1. 210
    0
      oa-ui/src/views/oa/supply/deviceList.vue

+ 210
- 0
oa-ui/src/views/oa/supply/deviceList.vue 查看文件

@@ -0,0 +1,210 @@
1
+<!--
2
+ * @Author: ysh
3
+ * @Date: 2024-06-21 18:51:51
4
+ * @LastEditors: Please set LastEditors
5
+ * @LastEditTime: 2024-07-30 15:36:16
6
+-->
7
+<template>
8
+  <div>
9
+    <el-form :inline="true">
10
+      <el-form-item label="设备类别:">
11
+        <el-select v-model="queryParams.type" filterable clearable @change="getList">
12
+          <el-option :value="'办公设备'" label="办公设备"></el-option>
13
+          <el-option :value="'仪器设备'" label="仪器设备"></el-option>
14
+        </el-select>
15
+      </el-form-item>
16
+      <el-form-item label="出厂编号:">
17
+        <el-input v-model="queryParams.code" clearable @keyup.enter.native="getList"></el-input>
18
+      </el-form-item>
19
+      <el-form-item label="设备状态:">
20
+        <el-select v-model="queryParams.status" filterable clearable @change="getList">
21
+          <el-option :value="'0'" label="被领用"></el-option>
22
+          <el-option :value="'1'" label="可领用"></el-option>
23
+          <el-option :value="'2'" label="维修中"></el-option>
24
+          <el-option :value="'3'" label="已停用"></el-option>
25
+          <el-option :value="'4'" label="已报废"></el-option>
26
+        </el-select>
27
+      </el-form-item>
28
+      <el-form-item label="设备名称:">
29
+        <el-select v-model="queryParams.name" filterable @change="getList" clearable>
30
+          <el-option v-for="item in nameList" :key="item.name" :label="item.name" :value="item.name">
31
+          </el-option>
32
+        </el-select>
33
+        <!-- <el-input v-model="queryParams.name" clearable></el-input> -->
34
+      </el-form-item>
35
+      <el-form-item label="品牌:">
36
+        <el-input v-model="queryParams.brand" clearable @keyup.enter.native="getList"></el-input>
37
+      </el-form-item>
38
+      <el-form-item>
39
+        <el-button @click="getList" type="primary">搜索</el-button>
40
+      </el-form-item>
41
+    </el-form>
42
+    <el-table ref="chooseDevice" :data="list" @selection-change="handleSelectionChange" :row-key="getRowKeys"
43
+      @current-change="handleCurrentChange" @row-dblclick="confirmChooseBySingle" :highlight-current-row="!multiple">
44
+      <el-table-column type="selection" width="50" align="center" :reserve-selection="true" v-if="multiple" />
45
+      <el-table-column label="设备状态" align="center" prop="status" v-if="queryParams.type == '仪器设备'">
46
+        <template slot-scope="scope">
47
+          <el-tag :type="statusType(scope.row.status)">
48
+            {{ statusTypeText(scope.row.status) }}
49
+          </el-tag>
50
+        </template>
51
+      </el-table-column>
52
+      <el-table-column label="出厂编号" align="center" prop="code" v-if="queryParams.type == '仪器设备'" />
53
+      <el-table-column label="设备品牌" align="center" prop="brand" />
54
+      <el-table-column label="设备名称" align="center" prop="name" />
55
+      <el-table-column label="规格型号" align="center" prop="series" />
56
+      <el-table-column label="存放地址" align="center" prop="place" />
57
+      <el-table-column label="单日成本" align="center" prop="dayCost" />
58
+    </el-table>
59
+    <div style="text-align: right;">
60
+      <el-pagination @current-change="getList" :current-page.sync="queryParams.pageNum"
61
+        :page-size="queryParams.pageSize" layout="total, prev, pager, next" :total="total">
62
+      </el-pagination>
63
+    </div>
64
+    <div>
65
+      已选设备:
66
+      <el-tag v-if="multiple" v-for="item in chooseList" style="margin: 5px;" :key="item.deviceIdId">
67
+        {{ item.name + '-' + item.series + '-' + item.brand }}
68
+      </el-tag>
69
+      <el-tag v-if="!multiple" style="margin: 5px;">{{ formatChooseList() }}</el-tag>
70
+      <div style="text-align: center;margin-top: 20px;">
71
+        <el-button type="primary" @click="confirmChoose">确认选择</el-button>
72
+        <el-button @click="clearChoose">清空选择</el-button>
73
+      </div>
74
+    </div>
75
+  </div>
76
+</template>
77
+
78
+<script>
79
+import { listDevice, listDeviceName } from "@/api/oa/device/device";
80
+import { multiply } from 'ol/transform';
81
+export default {
82
+  props: {
83
+    multiple: {
84
+      type: Boolean,
85
+      default: true
86
+    }
87
+  },
88
+  watch: {
89
+    multiple(newval) {
90
+      if (newval) {
91
+        this.chooseList = []
92
+      } else {
93
+        this.chooseList = {}
94
+      }
95
+      this.getList();
96
+      this.getNameList();
97
+    }
98
+  },
99
+  data() {
100
+    return {
101
+      queryParams: {
102
+        pageNum: 1,
103
+        pageSize: 10,
104
+        type: '办公设备'
105
+      },
106
+      list: [],
107
+      form: {},
108
+      total: 0,
109
+      loading: false,
110
+      chooseList: undefined,
111
+      nameList: [],
112
+    }
113
+  },
114
+  created() {
115
+    if (this.multiply) {
116
+      this.chooseList = []
117
+    } else {
118
+      this.chooseList = {}
119
+    }
120
+    this.getList();
121
+    this.getNameList();
122
+  },
123
+  methods: {
124
+    getList() {
125
+      this.loading = true;
126
+      listDevice(this.queryParams).then(response => {
127
+        this.list = response.rows;
128
+        this.total = response.total;
129
+        this.loading = false;
130
+        this.clearChoose();
131
+      });
132
+    },
133
+    getNameList() {
134
+      listDeviceName().then(res => {
135
+        this.nameList = res.data
136
+      })
137
+    },
138
+    handleSelectionChange(val) {
139
+      this.chooseList = val
140
+    },
141
+    handleCurrentChange(val) {
142
+      if (!this.multiple) {
143
+        this.chooseList = val
144
+      }
145
+    },
146
+    getRowKeys(row) {
147
+      return row.deviceId;
148
+    },
149
+    confirmChoose() {
150
+      this.$emit('chooseList', this.chooseList)
151
+    },
152
+    confirmChooseBySingle() {
153
+      if (!this.multiple) {
154
+        if (this.chooseList)
155
+          this.$emit('chooseList', this.chooseList)
156
+      }
157
+    },
158
+    clearChoose() {
159
+      if (this.multiple)
160
+        this.$refs.chooseDevice.clearSelection();
161
+      else {
162
+        this.chooseDevice = {}
163
+      }
164
+    },
165
+    statusTypeText(row) {
166
+      if (row == '0') {
167
+        return '被领用'
168
+      }
169
+      if (row == '1') {
170
+        return '可领用'
171
+      }
172
+      if (row == '2') {
173
+        return '维修中'
174
+      }
175
+      if (row == '3') {
176
+        return '已停用'
177
+      }
178
+      if (row == '4') {
179
+        return '已报废'
180
+      }
181
+    },
182
+    statusType(row) {
183
+      if (row == '0') {
184
+        return 'warning'
185
+      }
186
+      if (row == '1') {
187
+        return 'success'
188
+      }
189
+      if (row == '2') {
190
+        return 'info'
191
+      }
192
+      if (row == '3') {
193
+        return 'danger'
194
+      }
195
+      if (row == '4') {
196
+        return 'info'
197
+      }
198
+    },
199
+    formatChooseList() {
200
+      if (this.chooseList.name) {
201
+        return this.chooseList.name + '-' + this.chooseList.series + '-' + this.chooseList.brand
202
+      }else{
203
+        return null
204
+      }
205
+    }
206
+  }
207
+}
208
+</script>
209
+
210
+<style lang="scss" scoped></style>

Loading…
取消
儲存