浏览代码

功能:设备生产列表

chrislee 3 周之前
父节点
当前提交
9ea9be0aa2
共有 2 个文件被更改,包括 287 次插入0 次删除
  1. 114 0
      src/views/modules/common/device-component-v2.vue
  2. 173 0
      src/views/modules/device/production-record.vue

+ 114 - 0
src/views/modules/common/device-component-v2.vue

@@ -0,0 +1,114 @@
+<template>
+  <el-select
+    v-model="value"
+    ref="select"
+    placeholder="请选择"
+    clearable
+    filterable
+    remote
+    :remote-method="remoteMethod"
+    @change = "onChange"
+    @focus="cancelReadOnly"
+    @hook:mounted="cancelReadOnly"
+    @visible-change="cancelReadOnly"
+    style="width: 200px">
+    <el-option
+      v-for="item in options"
+      :key="item.value"
+      :label="item.label"
+      :value="item.value">
+    </el-option>
+    <el-option v-if="options.length > 0" label="加载更多" style="font-style: italic; color: #8a979e" value="undefined" @click.native="handleClick()"></el-option>
+  </el-select>
+</template>
+
+<script>
+import {getAllDeviceList} from '@/api/device'
+export default {
+  name: 'device-component-v2',
+  props: {
+    deviceId: {
+      type: String,
+      default: ''
+    },
+    device: {
+      type: Object,
+      default: () => {}
+    }
+  },
+  model: {
+    prop: 'deviceId',
+    event: 'deviceSelected'
+  },
+  data () {
+    return {
+      value: '',
+      current: 1,
+      size: 10,
+      name: '',
+      options: [],
+      loading: false,
+      noMore: false
+    }
+  },
+  mounted () {
+    this.init()
+  },
+  methods: {
+    async init () {
+      this.getList()
+    },
+    remoteMethod (query) {
+      this.options = []
+      this.current = 1
+      this.name = query
+      this.getList()
+    },
+    getList () {
+      getAllDeviceList({ 'name': this.name, 'current': this.current, 'size': this.size }).then(({data}) => {
+        if (data && data.code === '200') {
+          if (this.current > data.data.pages) {
+            return
+          }
+          data.data.records.forEach(item => {
+            this.options.push({
+              label: item.name,
+              value: item.id
+            })
+          })
+        } else {
+          this.options = []
+        }
+      })
+    },
+    handleClick () {
+      this.loadMore()
+    },
+    loadMore () {
+      this.current ++
+      this.getList()
+    },
+    onChange (item) {
+      if (item === 'undefined') {
+        this.value = null
+      }
+      this.$emit('deviceSelected', item)
+    },
+    cancelReadOnly (onOff) {
+      this.$nextTick(() => {
+        if (!onOff) {
+          const input = this.$refs.select.$el.querySelector('.el-input__inner')
+          const timer = setTimeout(() => {
+            input.removeAttribute('readonly')
+            clearTimeout(timer)
+          }, 200)
+        }
+      })
+    }
+  }
+}
+</script>
+
+<style scoped>
+
+</style>

+ 173 - 0
src/views/modules/device/production-record.vue

@@ -0,0 +1,173 @@
+<template>
+  <div class="device">
+    <template>
+      <!-- 查询、新增操作 -->
+      <el-form :inline="true" :model="dataForm" @keyup.enter.native="search()">
+        <el-form-item label="设备">
+          <device-component-v2 v-model="dataForm.equipmentId"/>
+        </el-form-item>
+        <el-form-item label="操机人">
+          <user-component v-model="dataForm.operatorId"/>
+        </el-form-item>
+        <el-form-item label="完成日期">
+          <el-date-picker
+            v-model="dataForm.date"
+            value-format="yyyy-MM-dd"
+            type="daterange"
+            range-separator="至"
+            start-placeholder="开始日期"
+            end-placeholder="结束日期">
+          </el-date-picker>
+        </el-form-item>
+        <el-form-item>
+          <el-button @click="search()">查询</el-button>
+        </el-form-item>
+      </el-form>
+      <!-- 数据表格 -->
+      <el-table
+        :data="dataList"
+        border
+        v-loading="dataListLoading"
+        style="width: 100%;">
+        <el-table-column
+          label="序号"
+          type="index"
+          width="50"
+          align="center">
+        </el-table-column>
+        <el-table-column
+          prop="deviceName"
+          header-align="center"
+          align="center"
+          min-width="140"
+          :show-overflow-tooltip="true"
+          label="设备名称">
+        </el-table-column>
+        <el-table-column
+          prop="deviceCode"
+          header-align="center"
+          align="center"
+          min-width="100"
+          :show-overflow-tooltip="true"
+          label="设备编号">
+        </el-table-column>
+        <el-table-column
+          prop="programName"
+          header-align="center"
+          align="center"
+          min-width="160"
+          :show-overflow-tooltip="true"
+          label="程序名称">
+        </el-table-column>
+        <el-table-column
+          prop="operatorName"
+          header-align="center"
+          align="center"
+          label="操机人">
+        </el-table-column>
+        <el-table-column
+          prop="completeTime"
+          header-align="center"
+          align="center"
+          min-width="160"
+          :show-overflow-tooltip="true"
+          label="完成时间">
+        </el-table-column>
+      </el-table>
+      <el-pagination
+        @size-change="sizeChangeHandle"
+        @current-change="currentChangeHandle"
+        :current-page="pageIndex"
+        :page-sizes="[10, 20, 50, 100]"
+        :page-size="pageSize"
+        :total="totalPage"
+        layout="total, sizes, prev, pager, next, jumper">
+      </el-pagination>
+    </template>
+  </div>
+</template>
+
+<script>
+import UserComponent from '../common/user-component'
+import DeviceComponentV2 from '../common/device-component-v2'
+import {isAuth} from '@/utils'
+import {getDate} from '@/utils/date-util'
+export default {
+  name: 'production-record',
+  components: {
+    UserComponent,
+    DeviceComponentV2
+  },
+  data () {
+    return {
+      addVisible: false,
+      dataForm: {},
+      dataList: [],
+      pageIndex: 1,
+      pageSize: 10,
+      totalPage: 0,
+      dataListLoading: false,
+      dataListSelections: []
+    }
+  },
+  created () {
+    this.getDataList()
+  },
+  methods: {
+    getDate,
+    isAuth,
+    onChose () {
+    },
+    // 查询
+    search () {
+      this.pageIndex = 1
+      this.getDataList()
+    },
+    // 获取数据列表
+    getDataList () {
+      this.dataListLoading = true
+      this.addVisible = false
+      this.$http({
+        url: this.$http.adornUrl('/biz-service/prodEquipmentRecord/list'),
+        method: 'get',
+        params: this.$http.adornParams({
+          'current': this.pageIndex,
+          'size': this.pageSize,
+          'dateStart': this.dataForm.date ? this.dataForm.date[0] : null,
+          'dateEnd': this.dataForm.date ? this.dataForm.date[1] : null,
+          'equipmentId': this.dataForm.equipmentId,
+          'operatorId': this.dataForm.operatorId
+        })
+      }).then(({data}) => {
+        if (data && data.code === '200') {
+          this.dataList = data.data.records
+          this.totalPage = Number(data.data.total)
+        } else {
+          this.dataList = []
+          this.totalPage = 0
+        }
+        this.dataListLoading = false
+      })
+    },
+    // 每页数
+    sizeChangeHandle (val) {
+      this.pageSize = val
+      this.pageIndex = 1
+      this.getDataList()
+    },
+    // 当前页
+    currentChangeHandle (val) {
+      this.pageIndex = val
+      this.getDataList()
+    },
+    // 多选
+    selectionChangeHandle (val) {
+      this.dataListSelections = val
+    }
+  }
+}
+</script>
+
+<style scoped>
+
+</style>