소스 검색

检定和报损

chrislee 6 달 전
부모
커밋
5f684ab1f1
3개의 변경된 파일291개의 추가작업 그리고 4개의 파일을 삭제
  1. 138 0
      src/views/modules/device/device-check.vue
  2. 125 0
      src/views/modules/device/device-damage.vue
  3. 28 4
      src/views/modules/device/device-list.vue

+ 138 - 0
src/views/modules/device/device-check.vue

@@ -0,0 +1,138 @@
+<template>
+  <div>
+    <div class="my-title">检定</div>
+    <el-form
+      :model="dataForm"
+      :rules="dataRule"
+      ref="dataForm"
+      @keyup.enter.native="dataFormSubmit()"
+      label-width="140px"
+    >
+      <el-row>
+        <el-col :span="8">
+          <el-form-item label="检定有效期(止)" prop="validityDate">
+            <el-date-picker
+              v-model="dataForm.validityDate"
+              type="datetime"
+              placeholder="选择日期"
+              value-format="yyyy-MM-dd HH:mm:ss"
+              style="width: 100%;" />
+          </el-form-item>
+        </el-col>
+        <el-col :span="8">
+          <el-form-item label="检定日期" prop="verificationDate">
+            <el-date-picker
+              v-model="dataForm.verificationDate"
+              type="datetime"
+              placeholder="选择日期"
+              value-format="yyyy-MM-dd HH:mm:ss"
+              style="width: 100%;" />
+          </el-form-item>
+        </el-col>
+      </el-row>
+      <el-row>
+        <el-col :span="24">
+          <el-form-item label="附件" prop="attachListVerification">
+            <upload-component
+              :accept="'*'"
+              :file-obj-list="fileList"
+              @uploadSuccess="uploadSuccess"/>
+          </el-form-item>
+        </el-col>
+      </el-row>
+    </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 UploadComponent from '../common/upload-component'
+export default {
+  name: 'device-check',
+  components: {UploadComponent},
+  data () {
+    return {
+      dataForm: {
+        id: 0,
+        validityDate: '',
+        verificationDate: '',
+        attachListVerification: []
+      },
+      fileList: [],
+      dataRule: {
+        validityDate: [{required: true, message: '请选择检定有效期(止)', trigger: 'change'}],
+        verificationDate: [{required: true, message: '请选择检定日期', trigger: 'change'}]
+      }
+    }
+  },
+  mounted () {},
+  methods: {
+    init (row) {
+      this.dataForm.id = row.id
+      this.dataForm.validityDate = row.validityDate
+      this.dataForm.verificationDate = row.verificationDate
+      if (row.attachListVerification && row.attachListVerification.length > 0) {
+        this.fileList = []
+        row.attachListVerification.forEach((item) => {
+          this.fileList.push({
+            name: item.fileName,
+            url: item.url,
+            id: item.url
+          })
+        })
+      }
+    },
+    onChose () {
+      this.$emit('onChose')
+    },
+    uploadSuccess (fileList) {
+      this.fileList = fileList
+    },
+    dataFormSubmit () {
+      this.$refs['dataForm'].validate((valid) => {
+        if (valid) {
+          // 添加附件
+          let fList = this.fileList
+          if (fList.length > 0) {
+            this.dataForm.attachListVerification = []
+            for (let i = 0; i < fList.length; i++) {
+              this.dataForm.attachListVerification.push({
+                fileName: fList[i].name,
+                url: fList[i].url
+              })
+            }
+          } else {
+            this.$message.error('请上传文件')
+            return
+          }
+          this.$http({
+            url: this.$http.adornUrl(`/biz-service/equipment/updateVerification`),
+            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>

+ 125 - 0
src/views/modules/device/device-damage.vue

@@ -0,0 +1,125 @@
+<template>
+  <div>
+    <div class="my-title">报损</div>
+    <el-form
+      :model="dataForm"
+      :rules="dataRule"
+      ref="dataForm"
+      @keyup.enter.native="dataFormSubmit()"
+      label-width="120px"
+    >
+      <el-row>
+        <el-col :span="24">
+          <el-form-item label="原因" prop="breakageCause">
+            <el-input
+              v-model="dataForm.breakageCause"
+              type="textarea"
+              placeholder="请输入原因"
+            ></el-input>
+          </el-form-item>
+        </el-col>
+      </el-row>
+      <el-row>
+        <el-col :span="24">
+          <el-form-item label="附件" prop="attachListBreakage">
+            <upload-component
+              :accept="'*'"
+              :file-obj-list="fileList"
+              @uploadSuccess="uploadSuccess"/>
+          </el-form-item>
+        </el-col>
+      </el-row>
+    </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 UploadComponent from '../common/upload-component'
+export default {
+  name: 'device-damage',
+  components: {UploadComponent},
+  data () {
+    return {
+      dataForm: {
+        id: 0,
+        breakageCause: '',
+        attachListBreakage: []
+      },
+      fileList: [],
+      dataRule: {
+        breakageCause: [{required: true, message: '请填写原因', trigger: 'blur'}]
+      }
+    }
+  },
+  mounted () {},
+  methods: {
+    init (row) {
+      this.dataForm.id = row.id
+      this.dataForm.breakageCause = row.breakageCause
+      // this.dataForm.attachListBreakage = row.attachListBreakage
+      if (row.attachListBreakage && row.attachListBreakage.length > 0) {
+        this.fileList = []
+        row.attachListBreakage.forEach((item) => {
+          this.fileList.push({
+            name: item.fileName,
+            url: item.url,
+            id: item.url
+          })
+        })
+      }
+    },
+    onChose () {
+      this.$emit('onChose')
+    },
+    uploadSuccess (fileList) {
+      this.fileList = fileList
+    },
+    dataFormSubmit () {
+      this.$refs['dataForm'].validate((valid) => {
+        if (valid) {
+          // 添加附件
+          let fList = this.fileList
+          if (fList.length > 0) {
+            this.dataForm.attachListBreakage = []
+            for (let i = 0; i < fList.length; i++) {
+              this.dataForm.attachListBreakage.push({
+                fileName: fList[i].name,
+                url: fList[i].url
+              })
+            }
+          } else {
+            this.$message.error('请上传文件')
+            return
+          }
+          this.$http({
+            url: this.$http.adornUrl(`/biz-service/equipment/updateBreakage`),
+            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>

+ 28 - 4
src/views/modules/device/device-list.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="device">
-    <template v-if="!addOrUpdateVisible && !detailVisible && !historyVisible">
+    <template v-if="!addOrUpdateVisible && !detailVisible && !historyVisible && !damageVisible && !checkVisible">
       <!-- 查询、新增操作 -->
       <el-form :inline="true" :model="dataForm" @keyup.enter.native="search()">
         <el-form-item label="名称/编号">
@@ -228,8 +228,8 @@
 <!--            <el-button v-if="isAuth('prod:equipment:info')" type="text" size="small" @click="detailHandle(scope.row.id)">查看</el-button>-->
             <el-button v-if="isAuth('prod:equipment:info')" type="text" size="small" @click="historyHandle(scope.row)">历史数据</el-button>
             <el-button v-if="isAuth('prod:equipment:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">编辑</el-button>
-            <el-button v-if="isAuth('prod:updateVerification:update')" type="text" size="small" @click="historyHandle(scope.row)">检定</el-button>
-            <el-button v-if="isAuth('prod:updateBreakage:update')" type="text" size="small" @click="historyHandle(scope.row)">报损</el-button>
+            <el-button v-if="isAuth('prod:updateVerification:update')" type="text" size="small" @click="checkHandle(scope.row)">检定</el-button>
+            <el-button v-if="isAuth('prod:updateBreakage:update')" type="text" size="small" @click="damageHandle(scope.row)">报损</el-button>
           </template>
         </el-table-column>
       </el-table>
@@ -248,6 +248,8 @@
     <detail v-if="detailVisible" ref="detail" @onChose="onChose"></detail>
     <device-history v-if="historyVisible" ref="history" @onChose="onChose"></device-history>
     <preview-component v-if="previewVisible" ref="preview" @onChose="onChose"></preview-component>
+    <device-damage v-if="damageVisible" ref="damage" @onChose="onChose" @refreshDataList="getDataList"></device-damage>
+    <device-check v-if="checkVisible" ref="check" @onChose="onChose" @refreshDataList="getDataList"></device-check>
   </div>
 </template>
 
@@ -261,9 +263,13 @@ import {optionsEquipmentState} from '@/utils/enums'
 import {isAuth} from '@/utils'
 import PreviewComponent from '@/views/modules/common/preview-component.vue'
 import DeviceHistory from '@/views/modules/device/device-history.vue'
+import DeviceDamage from '@/views/modules/device/device-damage.vue'
+import DeviceCheck from '@/views/modules/device/device-check.vue'
 export default {
-  name: 'temp',
+  name: 'device-list',
   components: {
+    DeviceCheck,
+    DeviceDamage,
     DeviceHistory,
     PreviewComponent,
     Detail,
@@ -278,6 +284,8 @@ export default {
       detailVisible: false,
       historyVisible: false,
       previewVisible: false,
+      damageVisible: false,
+      checkVisible: false,
       dataForm: {},
       dataList: [],
       pageIndex: 1,
@@ -297,6 +305,8 @@ export default {
       this.addOrUpdateVisible = false
       this.detailVisible = false
       this.historyVisible = false
+      this.damageVisible = false
+      this.checkVisible = false
     },
     // 查询
     search () {
@@ -369,6 +379,20 @@ export default {
         this.$refs.history.init(row.codeNumber)
       })
     },
+    // 报损
+    damageHandle (row) {
+      this.damageVisible = true
+      this.$nextTick(() => {
+        this.$refs.damage.init(row)
+      })
+    },
+    // 检定
+    checkHandle (row) {
+      this.checkVisible = true
+      this.$nextTick(() => {
+        this.$refs.check.init(row)
+      })
+    },
     // 删除
     deleteHandle (id) {
       if (!id) return