408249787 2 years ago
parent
commit
1447110a94

+ 1 - 1
src/utils/tool.js

@@ -988,7 +988,7 @@ BaseTool.UPLOAD = {
       if (BaseTool.String.isNotBlank(item.url)) {
         temp.push({
           url: GlobalConstant.BaseImageUrl + item.url,
-          uid: item.id,
+          uid: item.id ? item.id : item.url,
           name: item.name,
           value: item
         })

+ 169 - 169
src/views/tool/tool-log/modules/BaseForm.vue

@@ -1,185 +1,185 @@
 <template>
-    <a-card :bordered="false" v-show="visible" class="card" :title="modalTitle">
-        <a-row :gutter="48" slot="extra">
-            <a-col :md="48" :sm="48">
-              <span class="table-page-search-submitButtons" style="float: right">
-                <a-button :loading="confirmLoading" type="primary" @click="save()">保存</a-button>
-                <a-button style="margin-left: 8px" type="default" @click="handleCancel()">返回</a-button>
-              </span>
-            </a-col>
-        </a-row>
-        <a-form :form="form">
+  <a-card :bordered="false" v-show="visible" class="card" :title="modalTitle">
+    <a-row :gutter="48" slot="extra">
+      <a-col :md="48" :sm="48">
+        <span class="table-page-search-submitButtons" style="float: right">
+          <a-button :loading="confirmLoading" type="primary" @click="save()">保存</a-button>
+          <a-button style="margin-left: 8px" type="default" @click="handleCancel()">返回</a-button>
+        </span>
+      </a-col>
+    </a-row>
+    <a-form :form="form">
 
-            <a-form-item v-show="false">
-                <a-input v-decorator="['id']" type="hidden"/>
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </a-form-item>
+      <a-form-item v-show="false">
+        <a-input v-decorator="['id']" type="hidden"/>
+      </a-form-item>
 
-            <row-list :col="2">
-                                                                                                <row-item>
+      <row-list :col="2">
+        <row-item>
 
-                            <a-form-item
-                                    label="检验人"
-                                    :labelCol="BaseTool.Constant.labelCol"
-                                    :wrapperCol="BaseTool.Constant.wrapperCol"
-                            >
-                                                                    <a-input
-                                            v-decorator="['checkUserId', {rules: [{required: true, message: '检验人不能为空'}]}]"/>
-                                                            </a-form-item>
-                        </row-item>
-                                                                                <row-item>
+          <a-form-item
+            label="检验人"
+            :labelCol="BaseTool.Constant.labelCol"
+            :wrapperCol="BaseTool.Constant.wrapperCol"
+          >
+            <a-input
+              v-decorator="['checkUserId', {rules: [{required: true, message: '检验人不能为空'}]}]"/>
+          </a-form-item>
+        </row-item>
+        <row-item>
 
-                            <a-form-item
-                                    label="检验说明"
-                                    :labelCol="BaseTool.Constant.labelCol"
-                                    :wrapperCol="BaseTool.Constant.wrapperCol"
-                            >
-                                                                    <a-input
-                                            v-decorator="['requirement', {rules: [{required: true, message: '检验说明不能为空'}]}]"/>
-                                                            </a-form-item>
-                        </row-item>
-                                                                                <row-item>
+          <a-form-item
+            label="检验说明"
+            :labelCol="BaseTool.Constant.labelCol"
+            :wrapperCol="BaseTool.Constant.wrapperCol"
+          >
+            <a-input
+              v-decorator="['requirement', {rules: [{required: true, message: '检验说明不能为空'}]}]"/>
+          </a-form-item>
+        </row-item>
+        <row-item>
 
-                            <a-form-item
-                                    label="备注"
-                                    :labelCol="BaseTool.Constant.labelCol"
-                                    :wrapperCol="BaseTool.Constant.wrapperCol"
-                            >
-                                                                    <a-input
-                                            v-decorator="['remark', {rules: [{required: true, message: '备注不能为空'}]}]"/>
-                                                            </a-form-item>
-                        </row-item>
-                                                                                                                                                                                                                                                                                                        <row-item>
+          <a-form-item
+            label="备注"
+            :labelCol="BaseTool.Constant.labelCol"
+            :wrapperCol="BaseTool.Constant.wrapperCol"
+          >
+            <a-input
+              v-decorator="['remark', {rules: [{required: true, message: '备注不能为空'}]}]"/>
+          </a-form-item>
+        </row-item>
+        <row-item>
 
-                            <a-form-item
-                                    label="工器具id"
-                                    :labelCol="BaseTool.Constant.labelCol"
-                                    :wrapperCol="BaseTool.Constant.wrapperCol"
-                            >
-                                                                    <a-input
-                                            v-decorator="['toolId', {rules: [{required: true, message: '工器具id不能为空'}]}]"/>
-                                                            </a-form-item>
-                        </row-item>
-                                                                                <row-item>
+          <a-form-item
+            label="工器具id"
+            :labelCol="BaseTool.Constant.labelCol"
+            :wrapperCol="BaseTool.Constant.wrapperCol"
+          >
+            <a-input
+              v-decorator="['toolId', {rules: [{required: true, message: '工器具id不能为空'}]}]"/>
+          </a-form-item>
+        </row-item>
+        <row-item>
 
-                            <a-form-item
-                                    label="检测日期"
-                                    :labelCol="BaseTool.Constant.labelCol"
-                                    :wrapperCol="BaseTool.Constant.wrapperCol"
-                            >
-                                                                    <a-date-picker
-                                            style="width: 100%"
-                                            :format="BaseTool.Date.PICKER_NORM_DATE_PATTERN"
-                                            v-decorator="['checkDate', {rules: [{required: true, message: '检测日期不能为空'}]}]"/>
+          <a-form-item
+            label="检测日期"
+            :labelCol="BaseTool.Constant.labelCol"
+            :wrapperCol="BaseTool.Constant.wrapperCol"
+          >
+            <a-date-picker
+              style="width: 100%"
+              :format="BaseTool.Date.PICKER_NORM_DATE_PATTERN"
+              v-decorator="['checkDate', {rules: [{required: true, message: '检测日期不能为空'}]}]"/>
 
-                                                            </a-form-item>
-                        </row-item>
-                                                                                <row-item>
+          </a-form-item>
+        </row-item>
+        <row-item>
 
-                            <a-form-item
-                                    label="检定图片路径"
-                                    :labelCol="BaseTool.Constant.labelCol"
-                                    :wrapperCol="BaseTool.Constant.wrapperCol"
-                            >
-                                                                    <a-input
-                                            v-decorator="['imgPath', {rules: [{required: true, message: '检定图片路径不能为空'}]}]"/>
-                                                            </a-form-item>
-                        </row-item>
-                                                                                <row-item>
+          <a-form-item
+            label="检定图片路径"
+            :labelCol="BaseTool.Constant.labelCol"
+            :wrapperCol="BaseTool.Constant.wrapperCol"
+          >
+            <a-input
+              v-decorator="['imgPath', {rules: [{required: true, message: '检定图片路径不能为空'}]}]"/>
+          </a-form-item>
+        </row-item>
+        <row-item>
 
-                            <a-form-item
-                                    label="检定文件路径"
-                                    :labelCol="BaseTool.Constant.labelCol"
-                                    :wrapperCol="BaseTool.Constant.wrapperCol"
-                            >
-                                                                    <a-input
-                                            v-decorator="['filePath', {rules: [{required: true, message: '检定文件路径不能为空'}]}]"/>
-                                                            </a-form-item>
-                        </row-item>
-                                                </row-list>
-        </a-form>
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        </a-card>
+          <a-form-item
+            label="检定文件路径"
+            :labelCol="BaseTool.Constant.labelCol"
+            :wrapperCol="BaseTool.Constant.wrapperCol"
+          >
+            <a-input
+              v-decorator="['filePath', {rules: [{required: true, message: '检定文件路径不能为空'}]}]"/>
+          </a-form-item>
+        </row-item>
+      </row-list>
+    </a-form>
+  </a-card>
 </template>
 
 <script>
-    import pick from 'lodash.pick'
-    import {addToolLog, updateToolLog } from '@/api/tool/tool-log'
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        export default {
-        name: 'BaseToolLog',
-        data() {
-            return {
-                confirmLoading: false,
-                modalTitle: null,
-                form: this.$form.createForm(this),
-                visible: false,
-            // 下拉框map
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        }
-        },
-        props: {},
-        created() {
-            // 下拉框map
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        },
-        methods: {
-            base(record) {
-                this.visible = true
-                // 如果是空标识添加
-                if (this.BaseTool.Object.isBlank(record)) {
-                    this.modalTitle = '添加'
-                    return
-                }
-                this.modalTitle = '编辑'
-                const {form: {setFieldsValue}} = this
-                // 日期处理
-                                    record.checkDate = this.BaseTool.Moment(record.checkDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
-                                this.$nextTick(() => {
-                    setFieldsValue(Object.assign(pick(record, [
-                                                                                    'id',
-                                                                                                                'checkUserId',
-                                                                                                                'requirement',
-                                                                                                                'remark',
-                                                                                                                                                                                                                                                                                                                                                                                                                                        'toolId',
-                                                                                                                'checkDate',
-                                                                                                                'imgPath',
-                                                                                                                'filePath',
-                                                    ])))
-                })
-            },
-            save() {
-                const {form: {validateFieldsAndScroll}} = this
-                this.confirmLoading = true
-                validateFieldsAndScroll((errors, values) => {
-                    if (errors) {
-                        this.confirmLoading = false
-                        return
-                    }
-                    // 日期处理
-                                            values.checkDate = this.BaseTool.Date.formatter(values.checkDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
-                                        if (this.BaseTool.String.isBlank(values.id)) {
-                        addToolLog(values)
-                                .then(() => {
-                                    this.handleCancel(values)
-                                }).catch(() => {
-                            this.confirmLoading = false
-                        })
-                    } else {
-                        updateToolLog(values)
-                                .then(() => {
-                                    this.handleCancel(values)
-                                }).catch(() => {
-                            this.confirmLoading = false
-                        })
-                    }
-                })
-            },
-            handleCancel(values) {
-                this.visible = false
-                this.confirmLoading = false
-                this.form.resetFields()
-                if (this.BaseTool.Object.isNotBlank(values)) {
-                    this.$emit('ok', values)
-                } else {
-                    this.$emit('ok')
-                }
-            }
-                                                                                                                                                                                                                                                                                                                                                                                                                            }
+import pick from 'lodash.pick'
+import { addToolLog, updateToolLog } from '@/api/tool/tool-log'
+export default {
+  name: 'BaseToolLog',
+  data () {
+    return {
+      confirmLoading: false,
+      modalTitle: null,
+      form: this.$form.createForm(this),
+      visible: false
+      // 下拉框map
     }
+  },
+  props: {},
+  created () {
+    // 下拉框map
+  },
+  methods: {
+    base (record) {
+      this.visible = true
+      // 如果是空标识添加
+      if (this.BaseTool.Object.isBlank(record)) {
+        this.modalTitle = '添加'
+        return
+      }
+      this.modalTitle = '编辑'
+      const { form: { setFieldsValue } } = this
+      // 日期处理
+      record.checkDate = this.BaseTool.Moment(record.checkDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
+      this.$nextTick(() => {
+        setFieldsValue(Object.assign(pick(record, [
+          'id',
+          'checkUserId',
+          'requirement',
+          'remark',
+          'toolId',
+          'checkDate',
+          'imgPath',
+          'filePath'
+        ])))
+      })
+    },
+    save () {
+      const { form: { validateFieldsAndScroll } } = this
+      this.confirmLoading = true
+      validateFieldsAndScroll((errors, values) => {
+        if (errors) {
+          this.confirmLoading = false
+          return
+        }
+        // 日期处理
+        values.checkDate = this.BaseTool.Date.formatter(values.checkDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
+        if (this.BaseTool.String.isBlank(values.id)) {
+          addToolLog(values)
+            .then(() => {
+              this.handleCancel(values)
+            }).catch(() => {
+              this.confirmLoading = false
+            })
+        } else {
+          updateToolLog(values)
+            .then(() => {
+              this.handleCancel(values)
+            }).catch(() => {
+              this.confirmLoading = false
+            })
+        }
+      })
+    },
+    handleCancel (values) {
+      this.visible = false
+      this.confirmLoading = false
+      this.form.resetFields()
+      if (this.BaseTool.Object.isNotBlank(values)) {
+        this.$emit('ok', values)
+      } else {
+        this.$emit('ok')
+      }
+    }
+  }
+}
 </script>

+ 10 - 7
src/views/tool/tool/Tool.vue

@@ -35,9 +35,9 @@
                 <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
                   <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
                 </a-popconfirm>
-                <a-button title="是否要检定所选工器具?" @visibleChange="batchCheck()">
+                <a-popconfirm @visibleChange="batchCheck()">
                   <a-menu-item key="2"><my-icon type="icon-pandian" /><a>检定</a></a-menu-item>
-                </a-button>
+                </a-popconfirm>
               </a-menu>
               <a-button style="margin-left: 8px">
                 批量操作 <a-icon type="down" />
@@ -66,7 +66,7 @@
             >修改</operation-button>
             <operation-button
               v-if="$auth('tool-tools-edit')"
-              @click="batchCheck(record.id)"
+              @click="batchCheck(record)"
             >检定</operation-button>
             <operation-button
               v-if="$auth('tool-tools-del')"
@@ -79,6 +79,7 @@
     </div>
     <base-form ref="baseModal" @ok="handleOk"/>
     <detail ref="detailModal" @ok="handleOk"/>
+    <base-form-measure ref="baseModalMeasure" @ok="handleOk"/>
   </a-card>
 </template>
 
@@ -86,6 +87,8 @@
 import { STable, Ellipsis } from '@/components'
 import BaseForm from './modules/BaseForm'
 import Detail from './modules/Detail'
+import BaseFormMeasure from './modules/BaseFormMeasure'
+
 import { getToolPage, deleteTools, fetchTool, exportTool } from '@/api/tool/tool'
 
 export default {
@@ -93,6 +96,7 @@ export default {
   components: {
     STable,
     Ellipsis,
+    BaseFormMeasure,
     BaseForm,
     Detail
   },
@@ -297,10 +301,9 @@ export default {
       } else {
         ids = [id]
       }
-      this.$message.info('开发中')
-      // this.visible = false
-      // const modal = this.$refs.baseModalMeasure
-      // modal.base(ids, this.correctType)
+      this.visible = false
+      const modal = this.$refs.baseModalMeasure
+      modal.base(ids)
     },
     handleOk (values) {
       this.visible = true

+ 289 - 0
src/views/tool/tool/modules/BaseFormMeasure.vue

@@ -0,0 +1,289 @@
+<template>
+  <a-card :bordered="false" v-show="visible" class="card">
+    <a-row :gutter="48" style="position:fixed;bottom:150px;z-index:999;display:flex; justify-content: center;width: 90%;">
+      <a-col :md="48" :sm="48">
+        <span>
+          <a-button type="primary" @click="save()">保存</a-button>
+          <a-button style="margin-left: 8px" type="default" @click="handleCancel()">返回</a-button>
+        </span>
+      </a-col>
+    </a-row>
+    <div>
+      <div class="tables">
+        <div style="text-align:center;padding-bottom:10px;font-size:32px;">时代思康检定表</div>
+        <div style="display:flex; justify-content: space-between;">
+          <div> 检定人:{{ username }}</div>
+        </div>
+        <table>
+          <thead border="1px">
+            <tr>
+              <th width="100px">序号</th>
+              <th width="150px">工器具名称</th>
+              <th width="150px">工器具型号</th>
+              <th width="150px">编号</th>
+              <th width="150px">存放地点</th>
+              <th width="350px">检验说明</th>
+              <th width="150px">检定日期</th>
+              <th width="150px">备注</th>
+              <th width="150px">操作</th>
+            </tr>
+          </thead>
+          <tbody v-if="ListForm.length>0">
+            <tr v-for="(item,i) in ListForm" :key="item.id">
+              <td>{{ i+1 }}</td>
+              <td>{{ item.name }}</td>
+              <td>{{ item.ggxh }}</td>
+              <td> {{ item.no }}</td>
+              <td>{{ item.position }}</td>
+              <td><a-input style="width: 150px" v-model="item.requirement" /></td>
+              <td>
+                <a-date-picker
+                  show-time
+                  placeholder="日期"
+                  style="width: 150px"
+                  :format="BaseTool.Date.PICKER_NORM_DATETIME_PATTERN"
+                  v-model="item.checkDate" />
+              </td>
+              <td><a-input style="width: 150px" v-model="item.remark" /></td>
+              <td>
+                <a-button type="link" @click="uploadImg(item,i)">上传图片</a-button>
+                <a-button type="link" @click="uploadFile(item,i)">上传文件</a-button>
+                <a-modal v-model="uploadVisible" title="上传图片" :footer="null" @cancel="uploadVisible = false">
+                  <a-upload
+                    :action="uploadUrl"
+                    list-type="picture-card"
+                    :file-list="defaultApplicationFileList"
+                    @change="handleApplicationFileChange"
+                    @preview="handlePreview"
+                    accept="image/*"
+                    :headers="headers"
+                  >
+                    <div v-if="defaultApplicationFileList.length<1">
+                      <a-icon type="plus" />
+                      <div class="ant-upload-text">
+                        Upload
+                      </div>
+                    </div>
+                  </a-upload>
+                </a-modal>
+                <a-modal v-model="uploadFiledVisible" title="上传文件" :footer="null" @cancel="uploadFiledVisible = false">
+                  <a-upload
+                    :action="uploadUrl"
+                    :multiple="true"
+                    :file-list="defaultCheckFileList"
+                    @change="handleCheckFileChange"
+                    :headers="headers"
+                  >
+                    <a-button v-if="defaultCheckFileList.length<1"> <a-icon type="upload" /> 上传 </a-button>
+                  </a-upload>
+                </a-modal>
+                <a-modal :visible="previewVisible" :footer="null" @cancel="previewVisible = false" @ok="previewVisible = false">
+                  <img alt="example" style="width: 100%" :src="previewImage" />
+                </a-modal>
+              </td>
+            </tr>
+          </tbody>
+        </table>
+      </div>
+    </div>
+  </a-card>
+</template>
+
+<script>
+
+import { addToolLogBatch } from '@/api/tool/tool-log'
+
+import { uploadUrl } from '@/api/upms/file'
+import Vue from 'vue'
+import { ACCESS_TOKEN } from '@/store/mutation-types'
+
+export default {
+  name: 'BaseFillGatherTask',
+  components: {
+  },
+  data () {
+    return {
+      uploadUrl: uploadUrl,
+      defaultApplicationFileList: [],
+      defaultCheckFileList: [],
+      checkFileList: [], // 文档
+      applicationFileList: [],
+      headers: {
+        Authorization: 'Bearer ' + Vue.ls.get(ACCESS_TOKEN)
+      },
+      visible: false,
+      username: this.$store.getters.userInfo.username,
+      uploadVisible: false,
+      uploadFiledVisible: false,
+      previewVisible: false,
+      previewImage: '',
+      model: {},
+      listPage: {
+        pageNum: 1,
+        pageSize: 10,
+        total: 0
+      },
+      pagination: {
+        pageNum: 1,
+        pageSize: 10,
+        total: 0
+      },
+      imgId: '',
+      fileId: '',
+      ListForm: [],
+      id: '',
+      updatesInfo: []
+      // 下拉框map
+    }
+  },
+  props: {
+  },
+  created () {
+    // 下拉框map
+
+  },
+  methods: {
+    base (record) {
+      this.visible = true
+      this.model = record
+      console.log(record)
+      this.ListForm = record.map(item => {
+        const data = {
+          name: item.name,
+          ggxh: item.ggxh,
+          position: item.position,
+          no: item.no,
+          requirement: '',
+          remark: '',
+          checkDate: this.BaseTool.Date.formatter(new Date(), this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN),
+          checkImgList: [],
+          checkFileList: []
+        }
+        return data
+      })
+    },
+    uploadFile (val, i) {
+      this.uploadFiledVisible = true
+      this.fileId = i
+      console.log(val)
+      this.defaultCheckFileList = this.BaseTool.UPLOAD.transImg(val.checkFileList)
+    },
+    uploadImg (val, i) {
+      this.uploadVisible = true
+      this.imgId = i
+      console.log(this.BaseTool.UPLOAD.transImg(val.checkImgList))
+
+      this.defaultApplicationFileList = this.BaseTool.UPLOAD.transImg(val.checkImgList)
+    },
+    getBase64 (file) {
+      return new Promise((resolve, reject) => {
+        const reader = new FileReader()
+        reader.readAsDataURL(file)
+        reader.onload = () => resolve(reader.result)
+        reader.onerror = error => reject(error)
+      })
+    },
+    async handlePreview (file) {
+      if (!file.url && !file.preview) {
+        file.preview = await this.getBase64(file.originFileObj)
+      }
+      this.previewImage = file.url || file.preview
+      this.previewVisible = true
+    },
+    handleApplicationFileChange (info) {
+      this.defaultApplicationFileList = info.fileList
+      this.applicationFileList = this.setFileList(info, 11)
+      this.ListForm[this.imgId].checkImgList = this.applicationFileList
+    },
+    handleCheckFileChange (info) {
+      this.defaultCheckFileList = info.fileList
+      this.checkFileList = this.setFileList(info, 32)
+
+      this.ListForm[this.fileId].checkFileList = this.checkFileList
+      console.log(this.checkFileList)
+    },
+    setFileList (info, type) {
+      const file = info.file
+      const fileList = info.fileList
+      if (file.status === 'done') {
+        return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
+      } else if (file.status === 'removed') {
+        return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
+      } else if (file.status === 'error') {
+        this.$message.error('上传失败')
+        return []
+      }
+    },
+    save () {
+      console.log(this.ListForm)
+      let status = false
+      const params = this.ListForm.map(item => {
+        switch (true) {
+          case item.requirement === '' || item.requirement === null:
+            this.$message.warning(item.name + '检验说明不能为空')
+            status = true
+            return
+          case item.remark === '' || item.remark === null:
+            this.$message.warning(item.name + '备注不能为空')
+            status = true
+            return
+          case item.checkDate === '' || item.checkDate === null:
+            this.$message.warning(item.name + '的检定日期不能为空!')
+            status = true
+            return
+        }
+        return {
+          name: item.name,
+          ggxh: item.ggxh,
+          position: item.position,
+          no: item.no,
+          requirement: item.requirement,
+          remark: item.remark,
+          checkDate: this.BaseTool.Date.formatter(item.checkDate, this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN),
+          checkUserId: this.username,
+          imgPath: item.checkImgList.length > 0 ? item.checkImgList[0].url : '',
+          filePath: item.checkImgList.length > 0 ? item.checkImgList[0].url : ''
+        }
+      })
+      if (status) return
+      addToolLogBatch(params).then(res => {
+        this.$message.success('检定完成!')
+        this.handleCancel()
+      })
+    },
+    handleCancel () {
+      this.visible = false
+      this.ListForm = []
+      this.$emit('ok')
+    }
+  }
+}
+</script>
+<style lang="less" scoped>
+.tables{
+  margin: 20px 0px;
+  width: 100%;
+  overflow-x:auto;
+  table {
+    min-width:100%;
+    margin: 0 auto;
+    border: 1px solid #D6D6D6;
+    border-collapse: collapse;
+    font-size: 16px;
+    font-weight: 400;
+    table-layout:fixed;
+  }
+  th{
+    background: #fafafa;
+    font-weight: 500;
+
+  }
+  th,
+  td {
+    border: 1px solid #D6D6D6;
+    text-align: center;
+    padding: 5px 10px;
+    white-space: nowrap;
+  }
+}
+</style>