chrislee 5 mēneši atpakaļ
vecāks
revīzija
c8b87193b4

+ 17 - 0
src/api/device.js

@@ -7,6 +7,15 @@ export function getDeviceDetails (id) {
   })
 }
 
+// 获取可以上机的设备列表
+export function getDeviceList (params) {
+  return request({
+    url: request.adornUrl('/biz-service/equipment/listUp'),
+    method: 'get',
+    params: request.adornParams(params)
+  })
+}
+
 // 根据点检id获取设备点检信息
 export function getInspectionDetail (id) {
   return request({
@@ -30,3 +39,11 @@ export function getAlarmDetail (id) {
     method: 'get'
   })
 }
+
+// 根据设备使用记录id获取使用信息
+export function getUseDetail (id) {
+  return request({
+    url: request.adornUrl(`/biz-service/prodEquipmentUsageRecord/info/${id}`),
+    method: 'get'
+  })
+}

+ 1 - 0
src/icons/svg/icon-shiyong.svg

@@ -0,0 +1 @@
+<svg t="1734419744001" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7334" width="200" height="200"><path d="M645.12 143.36a51.2 51.2 0 0 1 51.2 51.2h88.7296c48.4352 0 91.136 32 95.232 77.1584l0.3584 7.2192V839.68a92.16 92.16 0 0 1-84.5824 91.8528l-7.5776 0.3072H238.9504c-48.4352 0-91.136-32-95.232-77.1584l-0.3584-7.2192V278.9376c0-46.4896 40.2432-80.7936 87.9616-84.1216l7.6288-0.256H337.92a51.2 51.2 0 0 1 51.2-51.2h256z m139.9296 133.12h-89.0368v0.8704a51.2 51.2 0 0 1-50.8928 45.2096h-256a51.2 51.2 0 0 1-50.944-46.08H238.9504a32.512 32.512 0 0 0-10.3424 1.5872l-2.9696 1.024-0.3584-0.1536v568.5248l0.3584-0.1536 2.9696 1.024c1.536 0.512 3.5328 1.024 6.0928 1.3312l4.2496 0.256H788.48a10.24 10.24 0 0 0 9.8816-7.5264l0.3584-2.7136V278.9376l-0.3584 0.1536-2.9696-1.024a31.232 31.232 0 0 0-6.0928-1.3312l-4.2496-0.256z m-357.9904 424.6016a30.72 30.72 0 0 1 1.9968 39.2704l-3.7376 4.096-68.4032 63.2832a30.72 30.72 0 0 1-38.5024 2.56l-4.1472-3.4816-33.9968-34.304a30.72 30.72 0 0 1 39.424-46.848l4.1984 3.584 13.1072 13.1584 46.592-43.008a30.72 30.72 0 0 1 43.4688 1.6896z m269.2608 20.8384a40.96 40.96 0 1 1 0 81.92H506.88a40.96 40.96 0 1 1 0-81.92h189.44z m-269.312-174.4384a30.72 30.72 0 0 1 2.048 39.2704l-3.7376 4.096-68.4032 63.2832a30.72 30.72 0 0 1-38.5024 2.56l-4.1472-3.4816-33.9968-34.304a30.72 30.72 0 0 1 39.424-46.848l4.1984 3.584 13.1072 13.1584 46.592-43.008a30.72 30.72 0 0 1 43.4688 1.6896z m269.312 10.5984a40.96 40.96 0 1 1 0 81.92H506.88a40.96 40.96 0 1 1 0-81.92h189.44zM427.008 393.8816a30.72 30.72 0 0 1 2.048 39.2704l-3.7376 4.096-68.4032 63.2832a30.72 30.72 0 0 1-38.5024 2.56l-4.1472-3.4816-33.9968-34.304a30.72 30.72 0 0 1 39.424-46.848l4.1984 3.584 13.1072 13.1584 46.592-43.008a30.72 30.72 0 0 1 43.4688 1.6896z m269.312 10.5984a40.96 40.96 0 1 1 0 81.92H506.88a40.96 40.96 0 1 1 0-81.92h189.44z m-71.5264-189.44H409.088v36.3008h215.7056v-36.352z" fill="#8A97A0" p-id="7335"></path></svg>

+ 6 - 0
src/utils/enums.js

@@ -156,3 +156,9 @@ export const optionsEquipmentRepairState = [
   {label: '待维修', value: '1'},
   {label: '已维修', value: '2'}
 ]
+
+// 使用状态(1:正在使用,2:使用结束)
+export const optionsUseState = [
+  {label: '正在使用', value: '1'},
+  {label: '使用结束', value: '2'}
+]

+ 114 - 0
src/views/modules/common/device-component.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 {getDeviceList} from '@/api/device'
+export default {
+  name: 'device-component',
+  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 () {
+      getDeviceList({ '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>

+ 74 - 0
src/views/modules/device/use-add.vue

@@ -0,0 +1,74 @@
+<template>
+  <div>
+      <div class="my-title">上机</div>
+      <!-- 表单 -->
+      <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="auto">
+        <el-form-item label="选择设备" prop="equipmentId">
+          <device-component v-model="dataForm.equipmentId" :device-id="dataForm.equipmentId"/>
+        </el-form-item>
+      </el-form>
+      <span slot="footer" class="dialog-footer">
+          <el-button @click="onChose">取消</el-button>
+          <el-button type="primary" @click="dataFormSubmit()" v-reClick>确定</el-button>
+      </span>
+  </div>
+</template>
+
+<script>
+  import DeviceComponent from '@/views/modules/common/device-component.vue'
+
+export default {
+    name: 'use-add',
+    components: {DeviceComponent},
+    data () {
+      return {
+        visible: false,
+        id: 0,
+        optionsModel: [],
+        dataForm: {},
+        dataRule: {
+          equipmentId: [{ required: true, message: '请选择设备', trigger: 'change' }]
+        }
+      }
+    },
+    methods: {
+      onChose () {
+        this.$emit('onChose')
+      },
+      async init () { },
+      validateField (type) {
+        this.$refs.dataForm.validateField(type)
+      },
+      // 表单提交
+      dataFormSubmit () {
+        this.$refs['dataForm'].validate((valid) => {
+          if (valid) {
+            this.$http({
+              url: this.$http.adornUrl(`/biz-service/prodEquipmentUsageRecord/insert`),
+              method: 'post',
+              data: this.$http.adornData({...this.dataForm})
+            }).then(({data}) => {
+              if (data && data.code === '200') {
+                this.$message({
+                  message: '操作成功',
+                  type: 'success',
+                  duration: 1500,
+                  onClose: () => {
+                    this.onChose()
+                    this.$emit('refreshDataList')
+                  }
+                })
+              } else {
+                this.$message.error(data.msg)
+              }
+            })
+          }
+        })
+      }
+    }
+  }
+</script>
+
+<style scoped>
+
+</style>

+ 69 - 0
src/views/modules/device/use-detail.vue

@@ -0,0 +1,69 @@
+<template>
+  <div>
+    <div class="my-title">查看</div>
+    <div style="margin-left: 20px;margin-right: 20px">
+      <e-desc title="基本信息" column="2" labelWidth="160px">
+        <e-desc-item label="设备名称">{{dataForm.equipmentName}}</e-desc-item>
+        <e-desc-item label="设备编号">{{dataForm.codeNumber}}</e-desc-item>
+        <e-desc-item label="状态">{{(state = optionsState.find(t => t.value === dataForm.state))? state.label:""}}</e-desc-item>
+        <e-desc-item label="使用人">{{dataForm.userOfName}}</e-desc-item>
+        <e-desc-item label="使用时间">{{dataForm.createTime}}</e-desc-item>
+      </e-desc>
+    </div>
+    <span slot="footer" class="dialog-footer">
+      <el-button @click="onChose">返回</el-button>
+    </span>
+  </div>
+</template>
+
+<script>
+  import EDesc from '../common/e-desc'
+  import EDescItem from '../common/e-desc-item'
+  import {getUseDetail} from '@/api/device'
+  import {getDate} from '@/utils/date-util'
+  import {optionsUseState} from '@/utils/enums'
+export default {
+    name: 'use-detail',
+    components: {
+      EDesc,
+      EDescItem
+    },
+    data () {
+      return {
+        visible: false,
+        id: 0,
+        dataForm: {},
+        optionsState: optionsUseState
+      }
+    },
+    methods: {
+      getDate,
+      onChose () {
+        this.$emit('onChose')
+      },
+      async init (id) {
+        this.visible = true
+        this.id = id || 0
+        this.dataForm = {}
+        this.getDetails()
+      },
+      getDetails () {
+        getUseDetail(this.id).then(({data}) => {
+          if (data && data.code === '200') {
+            this.dataForm = data.data
+          }
+        })
+      }
+    }
+  }
+</script>
+
+<style scoped>
+.my-line{
+  border-bottom: 1px solid #c0c4cc;
+  margin-bottom: 10px;
+}
+.title{
+  padding: 10px 0 ;
+}
+</style>

+ 239 - 0
src/views/modules/device/use-list.vue

@@ -0,0 +1,239 @@
+<template>
+  <div class="device">
+    <template v-if="!detailVisible && !addVisible">
+      <!-- 查询、新增操作 -->
+      <el-form :inline="true" :model="dataForm" @keyup.enter.native="search()">
+        <el-form-item label="名称/编号">
+          <el-input v-model="dataForm.name" placeholder="名称/编号" clearable/>
+        </el-form-item>
+        <el-form-item label="使用人">
+          <user-component v-model="dataForm.userOf"/>
+        </el-form-item>
+        <el-form-item label="使用日期">
+          <el-date-picker
+            v-model="dataForm.date"
+            value-format="yyyy-MM-dd HH:mm:ss"
+            type="daterange"
+            range-separator="至"
+            start-placeholder="开始日期"
+            end-placeholder="结束日期">
+          </el-date-picker>
+        </el-form-item>
+        <el-form-item>
+          <el-button @click="search()">查询</el-button>
+          <el-button v-if="isAuth('prod:prodEquipmentUsageRecord:insert')" type="primary" @click="addHandle()">上机</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="equipmentName"
+          header-align="center"
+          align="center"
+          min-width="140"
+          :show-overflow-tooltip="true"
+          label="设备名称">
+        </el-table-column>
+        <el-table-column
+          prop="codeNumber"
+          header-align="center"
+          align="center"
+          min-width="100"
+          :show-overflow-tooltip="true"
+          label="设备编号">
+        </el-table-column>
+        <el-table-column
+          prop="createTime"
+          header-align="center"
+          align="center"
+          min-width="160"
+          :show-overflow-tooltip="true"
+          label="使用时间">
+        </el-table-column>
+        <el-table-column
+          prop="userOfName"
+          header-align="center"
+          align="center"
+          label="使用人">
+        </el-table-column>
+        <el-table-column
+          prop="state"
+          fixed="right"
+          header-align="center"
+          align="center"
+          label="状态">
+          <template slot-scope="scope">
+            {{optionsState.find(t => t.value === scope.row.state).label}}
+          </template>
+        </el-table-column>
+        <el-table-column
+          fixed="right"
+          header-align="center"
+          align="center"
+          width="100"
+          label="操作">
+          <template slot-scope="scope">
+            <el-button v-if="isAuth('prod:prodEquipmentUsageRecord:info')" type="text" size="small" @click="detailHandle(scope.row.usageRecordId)">查看</el-button>
+            <el-button v-if="isAuth('prod:prodEquipmentUsageRecord:update') && Number(scope.row.state) === 1 && scope.row.creatorId === userId" type="text" size="small" @click="downHandle(scope.row)">下机</el-button>
+          </template>
+        </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>
+    <detail v-if="detailVisible" ref="detail" @onChose="onChose"></detail>
+    <use-add v-if="addVisible" ref="add" @onChose="onChose" @refreshDataList="getDataList"></use-add>
+  </div>
+</template>
+
+<script>
+import Detail from './use-detail'
+import UserComponent from '../common/user-component'
+import {optionsUseState} from '@/utils/enums'
+import {isAuth} from '@/utils'
+import {getDate} from '@/utils/date-util'
+import UseAdd from './use-add.vue'
+export default {
+  name: 'use-list',
+  components: {
+    UseAdd,
+    Detail,
+    UserComponent
+  },
+  data () {
+    return {
+      addVisible: false,
+      detailVisible: false,
+      dataForm: {},
+      dataList: [],
+      pageIndex: 1,
+      pageSize: 10,
+      totalPage: 0,
+      dataListLoading: false,
+      dataListSelections: [],
+      optionsState: optionsUseState,
+      userId: this.$store.state.user.id
+    }
+  },
+  created () {
+    this.getDataList()
+  },
+  methods: {
+    getDate,
+    isAuth,
+    onChose () {
+      this.detailVisible = false
+      this.addVisible = false
+    },
+    // 查询
+    search () {
+      this.pageIndex = 1
+      this.getDataList()
+    },
+    // 获取数据列表
+    getDataList () {
+      this.dataListLoading = true
+      this.addVisible = false
+      this.$http({
+        url: this.$http.adornUrl('/biz-service/prodEquipmentUsageRecord/list'),
+        method: 'get',
+        params: this.$http.adornParams({
+          'current': this.pageIndex,
+          'size': this.pageSize,
+          'userOf': this.dataForm.userOf ? this.dataForm.userOf : null,
+          'name': this.dataForm.name ? this.dataForm.name : null,
+          'dateStart': this.dataForm.date ? this.dataForm.date[0] : null,
+          'dateEnd': this.dataForm.date ? this.dataForm.date[1] : null
+        })
+      }).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
+    },
+    // 新增 / 修改
+    addHandle () {
+      this.addVisible = true
+      this.$nextTick(() => {
+        this.$refs.add.init()
+      })
+    },
+    // 查看
+    detailHandle (id) {
+      this.detailVisible = true
+      this.$nextTick(() => {
+        this.$refs.detail.init(id)
+      })
+    },
+    // 下机
+    downHandle (row) {
+      this.$confirm('设备下机,是否继续操作?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        this.$http({
+          url: this.$http.adornUrl('/biz-service/prodEquipmentUsageRecord/update'),
+          method: 'post',
+          data: this.$http.adornData({
+            ...row
+          })
+        }).then(({data}) => {
+          if (data && data.code === '200') {
+            this.$message({
+              message: '操作成功',
+              type: 'success',
+              duration: 1500,
+              onClose: () => {
+                this.onChose()
+                this.$emit('refreshDataList')
+              }
+            })
+          }
+        })
+      })
+    }
+  }
+}
+</script>
+
+<style scoped>
+
+</style>