소스 검색

报告归档调整,附件类型校验bug修改

cfort 3 년 전
부모
커밋
97509632e9

+ 281 - 282
src/business/platform/file/uploader/index.vue

@@ -1,291 +1,290 @@
 <template>
-  <el-dialog
-    v-if="dialogVisible"
-    :visible.sync="dialogVisible"
-    :close-on-click-modal="false"
-    :close-on-press-escape="false"
-    :title="title"
-    :top="marginTop"
-    append-to-body
-    custom-class="ibps-uploader-dialog"
-    @close="closeDialog"
-  >
-    <el-tabs
-      v-model="activeName"
-      class="uploader-tab"
-      @tab-click="onTabClick"
+    <el-dialog
+        v-if="dialogVisible"
+        :visible.sync="dialogVisible"
+        :close-on-click-modal="false"
+        :close-on-press-escape="false"
+        :title="title"
+        :top="marginTop"
+        append-to-body
+        custom-class="ibps-uploader-dialog"
+        @close="closeDialog"
     >
-      <el-tab-pane label="当前上传附件" name="upload">
-        <upload
-          ref="upload"
-          :multiple="multiple"
-          :file-size="size"
-          :accept="acceptRule"
-          :height="height"
-          :init="dialogVisible"
-          :limit="limit"
-          @callback="uploadCallback"
-        />
-      </el-tab-pane>
-      <el-tab-pane label="选择历史上传附件" name="online">
-        <online
-          ref="online"
-          :multiple="multiple"
-          :file-size="size"
-          :height="height"
-          :accept="acceptRule"
-          :limit="limit"
-          :load="onlineLoad"
-          @format="onFormat"
-          @callback="onlineCallback"
-        />
-      </el-tab-pane>
-    </el-tabs>
-    <div slot="footer" class="el-dialog--center">
-      <ibps-toolbar
-        :actions="toolbars"
-        @action-event="handleActionEvent"
-      />
-    </div>
-  </el-dialog>
+        <el-tabs
+            v-model="activeName"
+            class="uploader-tab"
+            @tab-click="onTabClick"
+        >
+            <el-tab-pane label="当前上传附件" name="upload">
+                <upload
+                    ref="upload"
+                    :multiple="multiple"
+                    :file-size="size"
+                    :accept="acceptRule"
+                    :height="height"
+                    :init="dialogVisible"
+                    :limit="limit"
+                    @callback="uploadCallback"
+                />
+            </el-tab-pane>
+            <el-tab-pane label="选择历史上传附件" name="online">
+                <online
+                    ref="online"
+                    :multiple="multiple"
+                    :file-size="size"
+                    :height="height"
+                    :accept="acceptRule"
+                    :limit="limit"
+                    :load="onlineLoad"
+                    @format="onFormat"
+                    @callback="onlineCallback"
+                />
+            </el-tab-pane>
+        </el-tabs>
+        <div slot="footer" class="el-dialog--center">
+            <ibps-toolbar
+                :actions="toolbars"
+                @action-event="handleActionEvent"
+            />
+        </div>
+    </el-dialog>
 </template>
 
 <script>
-import { fileTypes, allFileTypes, accept as acceptTypes } from '@/business/platform/file/constants/fileTypes'
-import upload from './upload'
-import online from './online'
+    import { fileTypes, allFileTypes, accept as acceptTypes} from '@/business/platform/file/constants/fileTypes'
+    import upload from './upload'
+    import online from './online'
 
-export default {
-  components: {
-    upload,
-    online
-  },
-  props: {
-    value: {
-      type: [String, Number, Array, Object]
-    },
-    multiple: {
-      type: Boolean,
-      default: false
-    },
-    visible: {
-      type: Boolean,
-      default: false
-    },
-    title: {
-      type: String,
-      default: '文件上传'
-    },
-    marginTop: {
-      type: String,
-      default: '5vh'
-    },
-    height: {
-      type: String,
-      default: '400px'
-    },
-    fileSize: [Number, String],
-    limit: {
-      type: Number
-    },
-    accept: {
-      type: String,
-      default: ''
-    },
-    fileExt: {
-      type: Array,
-      default: () => []
-    }
-  },
-  data() {
-    return {
-      dialogVisible: this.visible,
-      activeName: 'upload',
-      buttonKey: 'confirm',
-      onlineLoad: false,
-      format: true,
-
-      fileTypes: fileTypes,
-      allFileTypes: allFileTypes,
-      acceptTypes: acceptTypes,
-      size: null,
-      targetExt: false,
-      acceptRule: '',
-      uploadFileList: [],
-      onlineFileList: [],
-      fileList: this.multiple ? [] : {},
-      toolbars: [
-        { key: 'confirm' ,type: 'primary', label:'文件上传'},
-        { key: 'cancel' }
-      ]
-    }
-  },
-  watch: {
-    visible: {
-      handler: function(val, oldVal) {
-        this.dialogVisible = this.visible
-        this.activeName = 'upload'
-        this.uploadFileList = []
-      },
-      immediate: true
-    },
-    accept: {
-      handler: function(val, oldVal) {
-        if (val === '*' && this.fileExt.length !== 0) {
-          const str = '.' + this.fileExt.join(',').replace(/,/g, ',.')
-          this.acceptRule = str
-        } else {
-          this.acceptRule = val
-        }
-      },
-      immediate: true
-    },
-    fileSize: {
-      handler: function(val, oldVal) {
-        if (this.$utils.isNotEmpty(val)) {
-          this.size = typeof val === 'number' ? val * 1024 * 1024 : parseFloat(val) * 1024 * 1024
-        }
-      },
-      immediate: true
-    }
-  },
-  methods: {
-    handleActionEvent({ key }) {
-      switch (key) {
-        case 'confirm':
-          this.handleConfirm()
-          break
-        case 'cancel':
-          this.closeDialog()
-          break
-        default:
-          break
-      }
-    },
-    uploadCallback(data) {
-      this.uploadFileList = data
-      if (this.multiple) {
-        this.fileList = this.$utils.isNotEmpty(this.value) ? [...this.value, ...this.uploadFileList] : this.uploadFileList
-      } else {
-        this.onlineFileList = []
-        this.fileList = this.uploadFileList
-      }
-    },
-    onlineCallback(data) {
-      this.onlineFileList = data
-      if (this.multiple) {
-        this.fileList = this.$utils.isNotEmpty(this.value) ? [...this.uploadFileList, ...data, ...this.value] : data
-      } else {
-        this.uploadFileList = []
-        this.fileList = data
-      }
-    },
-    // 关闭当前窗口
-    closeDialog() {
-      this.uploadFileList = []
-      this.onlineFileList = []
-      this.$emit('close', false)
-    },
-    onTabClick(tab) {
-      if (tab.name === 'online') {
-        this.onlineLoad = !this.onlineLoad
-      }
-    },
-    onFormat(format) {
-      this.format = format
-    },
-    /**
-     * 文件类型的限制
-     */
-    fileExtType() {
-      const accept = this.accept
-      const acceptTypes = this.acceptTypes
-      const fileTypes = this.fileTypes
-      let type = ''
-      let targetFileTypes = []
-      this.targetExt = false
-      for (const i in acceptTypes) {
-        if (acceptTypes[i] === accept) {
-          type = i
-          targetFileTypes = fileTypes[i]
-        } else {
-          if (accept === '*') {
-            // 不限制
-            targetFileTypes = '*'
-          } else {
-            // 自定义
-            targetFileTypes = accept.split(',')
-          }
-        }
-      }
-      const fileList = this.multiple ? this.fileList : [this.fileList]
-      if (targetFileTypes !== '*') {
-        this.targetExt = fileList.every(i => {
-          // console.log(targetFileTypes, `.${i.ext}`) // 控件类型集,过滤文件得后缀
-          if (type === 'compress') {
-            return targetFileTypes.includes(`${i.ext}`)
-          } else {
-            return targetFileTypes.includes(`.${i.ext}`)
-          }
-        })
-      } else {
-        this.targetExt = true
-      }
-      // console.log(fileList, this.targetExt, 'lll') // 已上传文件,过滤结果
-      return this.targetExt
-    },
-    handleConfirm() {
-      const arr = []
-      if (!this.multiple) {
-        if (this.$utils.isNotEmpty(this.uploadFileList)) {
-          arr.push(this.uploadFileList)
-          this.fileList = this.uploadFileList
-        }
-        if (this.$utils.isNotEmpty(this.onlineFileList)) {
-          arr.push(this.onlineFileList)
-          this.fileList = this.onlineFileList
-        }
-      }
-      // console.log(this.fileList, 'fileList')
-      if (this.$utils.isNotEmpty(arr) && arr.length > 1) {
-        this.$message.closeAll()
-        this.$message({
-          message: '附件上传设置为单选,选择文件数量只能为1个',
-          type: 'warning'
-        })
-        return
-      }
-      if (this.$utils.isNotEmpty(this.limit) && this.limit < this.fileList.length) {
-        this.$message.closeAll()
-        this.$message({
-          message: '超过设置最大上传数量限制' + this.limit,
-          type: 'warning'
-        })
-        return
-      }
-      if (!this.fileExtType()) {
-        this.$message.closeAll()
-        this.$message({
-          message: '选择的附件中存在不符合规定类型的文件,请重新选择!',
-          type: 'warning'
-        })
-        return
-      }
-      if (!this.format) {
-        this.$message.closeAll()
-        this.$message.error('选择文件格式不允许!')
-      } else {
-        if (this.$utils.isEmpty(this.fileList)) {
-          this.$message.closeAll()
-          this.$message({
-            message: '请上传或选择文件,或待文件上传成功后在继续操作!',
-            type: 'warning'
-          })
-          return
+    export default {
+        components: {
+            upload,
+            online
+        },
+        props: {
+            value: {
+                type: [String, Number, Array, Object]
+            },
+            multiple: {
+                type: Boolean,
+                default: false
+            },
+            visible: {
+                type: Boolean,
+                default: false
+            },
+            title: {
+                type: String,
+                default: '文件上传'
+            },
+            marginTop: {
+                type: String,
+                default: '5vh'
+            },
+            height: {
+                type: String,
+                default: '400px'
+            },
+            fileSize: [Number, String],
+            limit: {
+                type: Number
+            },
+            accept: {
+                type: String,
+                default: ''
+            },
+            fileExt: {
+                type: Array,
+                default: () => []
+            }
+        },
+        data() {
+            return {
+                dialogVisible: this.visible,
+                activeName: 'upload',
+                buttonKey: 'confirm',
+                onlineLoad: false,
+                format: true,
+                fileTypes: fileTypes,
+                allFileTypes: allFileTypes,
+                acceptTypes: acceptTypes,
+                size: null,
+                targetExt: false,
+                acceptRule: '',
+                uploadFileList: [],
+                onlineFileList: [],
+                fileList: this.multiple ? [] : {},
+                toolbars: [
+                    { key: 'confirm', type: 'primary', label: '文件上传' },
+                    { key: 'cancel' }
+                ]
+            }
+        },
+        watch: {
+            visible: {
+                handler: function (val, oldVal) {
+                    this.dialogVisible = this.visible
+                    this.activeName = 'upload'
+                    this.uploadFileList = []
+                },
+                immediate: true
+            },
+            accept: {
+                handler: function (val, oldVal) {
+                    if (val === '*' && this.fileExt.length !== 0) {
+                        const str = '.' + this.fileExt.join(',').replace(/,/g, ',.')
+                        this.acceptRule = str
+                    } else {
+                        this.acceptRule = val
+                    }
+                },
+                immediate: true
+            },
+            fileSize: {
+                handler: function (val, oldVal) {
+                    if (this.$utils.isNotEmpty(val)) {
+                        this.size = typeof val === 'number' ? val * 1024 * 1024 : parseFloat(val) * 1024 * 1024
+                    }
+                },
+                immediate: true
+            }
+        },
+        methods: {
+            handleActionEvent({ key }) {
+                switch (key) {
+                    case 'confirm':
+                        this.handleConfirm()
+                        break
+                    case 'cancel':
+                        this.closeDialog()
+                        break
+                    default:
+                        break
+                }
+            },
+            uploadCallback(data) {
+                this.uploadFileList = data
+                if (this.multiple) {
+                    this.fileList = this.$utils.isNotEmpty(this.value) ? [...this.value, ...this.uploadFileList] : this.uploadFileList
+                } else {
+                    this.onlineFileList = []
+                    this.fileList = this.uploadFileList
+                }
+            },
+            onlineCallback(data) {
+                this.onlineFileList = data
+                if (this.multiple) {
+                    this.fileList = this.$utils.isNotEmpty(this.value) ? [...this.uploadFileList, ...data, ...this.value] : data
+                } else {
+                    this.uploadFileList = []
+                    this.fileList = data
+                }
+            },
+            // 关闭当前窗口
+            closeDialog() {
+                this.uploadFileList = []
+                this.onlineFileList = []
+                this.$emit('close', false)
+            },
+            onTabClick(tab) {
+                if (tab.name === 'online') {
+                    this.onlineLoad = !this.onlineLoad
+                }
+            },
+            onFormat(format) {
+                this.format = format
+            },
+            /**
+             * 文件类型的限制
+             */
+            fileExtType() {
+                const accept = this.accept
+                const acceptTypes = this.acceptTypes
+                const fileTypes = this.fileTypes
+                let type = ''
+                let targetFileTypes = []
+                this.targetExt = false
+                for (const i in acceptTypes) {
+                    if (acceptTypes[i] === accept) {
+                        type = i
+                        targetFileTypes = fileTypes[i]
+                    } else {
+                        if (accept === '*') {
+                            // 不限制
+                            targetFileTypes = '*'
+                        } else {
+                            // 自定义
+                            targetFileTypes = accept.split(',')
+                        }
+                    }
+                }
+                const fileList = this.multiple ? this.fileList : [this.fileList]
+                if (targetFileTypes !== '*') {
+                    this.targetExt = fileList.every(i => {
+                        // console.log(targetFileTypes, `.${i.ext}`) // 控件类型集,过滤文件得后缀
+                        if (type === 'compress') {
+                            return targetFileTypes.includes(`${i.ext}`)
+                        } else {
+                            return targetFileTypes.includes(`${i.ext}`)
+                        }
+                    })
+                } else {
+                    this.targetExt = true
+                }
+                // console.log(fileList, this.targetExt, 'lll') // 已上传文件,过滤结果
+                return this.targetExt
+            },
+            handleConfirm() {
+                const arr = []
+                if (!this.multiple) {
+                    if (this.$utils.isNotEmpty(this.uploadFileList)) {
+                        arr.push(this.uploadFileList)
+                        this.fileList = this.uploadFileList
+                    }
+                    if (this.$utils.isNotEmpty(this.onlineFileList)) {
+                        arr.push(this.onlineFileList)
+                        this.fileList = this.onlineFileList
+                    }
+                }
+                // console.log(this.fileList, 'fileList')
+                if (this.$utils.isNotEmpty(arr) && arr.length > 1) {
+                    this.$message.closeAll()
+                    this.$message({
+                        message: '附件上传设置为单选,选择文件数量只能为1个',
+                        type: 'warning'
+                    })
+                    return
+                }
+                if (this.$utils.isNotEmpty(this.limit) && this.limit < this.fileList.length) {
+                    this.$message.closeAll()
+                    this.$message({
+                        message: '超过设置最大上传数量限制' + this.limit,
+                        type: 'warning'
+                    })
+                    return
+                }
+                if (!this.fileExtType()) {
+                    this.$message.closeAll()
+                    this.$message({
+                        message: '选择的附件中存在不符合规定类型的文件,请重新选择!',
+                        type: 'warning'
+                    })
+                    return
+                }
+                if (!this.format) {
+                    this.$message.closeAll()
+                    this.$message.error('选择文件格式不允许!')
+                } else {
+                    if (this.$utils.isEmpty(this.fileList)) {
+                        this.$message.closeAll()
+                        this.$message({
+                            message: '请上传或选择文件,或待文件上传成功后在继续操作!',
+                            type: 'warning'
+                        })
+                        return
+                    }
+                    this.$emit('action-event', this.buttonKey, this.fileList)
+                }
+            }
         }
-        this.$emit('action-event', this.buttonKey, this.fileList)
-      }
     }
-  }
-}
 </script>

+ 312 - 312
src/business/platform/file/uploader/online.vue

@@ -1,319 +1,319 @@
 <template>
-  <div
-    :style="{
-      height:height
-    }"
-  >
-    <el-form :model="form" :inline="true" @keyup.enter.native="onSearch" @submit.native.prevent>
-      <el-form-item label="文件名" prop="name">
-        <el-input v-model="form.name" placeholder="文件名" @keyup.enter.native="onSearch" />
-      </el-form-item>
-      <el-form-item>
-        <el-button type="primary" @click="onSearch">查询</el-button>
-      </el-form-item>
-    </el-form>
-    <el-table
-      ref="elTable"
-      :data="listData"
-      :row-key="getRowKey"
-      height="340"
-      border
-      @row-click="handleRowClick"
-      @selection-change="handleSelectionChange"
-    >
-      <!--选择列 多选-->
-      <el-table-column
-        v-if="(selectionRow || selectionRow === '') && selectionType === 'checkbox'"
-        v-bind="typeof selectionRow === 'Object'?selectionRow:null"
-        :label="handleAttribute(selectionRow.label, '')"
-        :reserve-selection="true"
-        type="selection"
-      />
-      <!--选择列 单选-->
-      <el-table-column
-        v-if="(selectionRow || selectionRow === '') && selectionType === 'radio'"
-        :label="selectionRow.label||''"
-        :width="selectionRow.width||55"
-      >
-        <template slot-scope="scope">
-          <div @click.stop>
-            <el-radio v-model="selectionRadio" :label="scope.row[pkKey]" @change="changeRowRadio(scope.row)"><span>&nbsp;</span></el-radio>
-          </div>
-        </template>
-      </el-table-column>
-      <el-table-column label="文件名" prop="fileName" />
-      <el-table-column label="扩展名" prop="ext" />
-    </el-table>
-    <el-pagination
-      :current-page="currentPage"
-      :page-size="pageSize"
-      :page-count="pagination[pageCountKey]"
-      :total="pagination[totalKey]"
-      @size-change="handlePaginationSizeChange"
-      @current-change="handlePaginationCurrentChange"
-      @prev-click="handlePaginationPrevClick"
-      @next-click="handlePaginationNextClick"
-    />
-  </div>
+    <div :style="{ height: height }">
+        <el-form :model="form" :inline="true" @keyup.enter.native="onSearch" @submit.native.prevent>
+            <el-form-item label="文件名" prop="name">
+                <el-input v-model="form.name" placeholder="文件名" @keyup.enter.native="onSearch" />
+            </el-form-item>
+            <el-form-item>
+                <el-button type="primary" @click="onSearch">查询</el-button>
+            </el-form-item>
+        </el-form>
+        <el-table
+            ref="elTable"
+            :data="listData"
+            :row-key="getRowKey"
+            height="340"
+            border
+            @row-click="handleRowClick"
+            @selection-change="handleSelectionChange"
+        >
+            <!--选择列 多选-->
+            <el-table-column
+                v-if="(selectionRow || selectionRow === '') && selectionType === 'checkbox'"
+                v-bind="typeof selectionRow === 'Object' ? selectionRow : null"
+                :label="handleAttribute(selectionRow.label, '')"
+                :reserve-selection="true"
+                type="selection"
+            />
+            <!--选择列 单选-->
+            <el-table-column
+                v-if="(selectionRow || selectionRow === '') && selectionType === 'radio'"
+                :label="selectionRow.label || ''"
+                :width="selectionRow.width || 55"
+            >
+                <template slot-scope="scope">
+                    <div @click.stop>
+                        <el-radio v-model="selectionRadio" :label="scope.row[pkKey]" @change="changeRowRadio(scope.row)">
+                            <span>&nbsp;</span>
+                        </el-radio>
+                    </div>
+                </template>
+            </el-table-column>
+            <el-table-column label="文件名" prop="fileName" />
+            <el-table-column label="扩展名" prop="ext" />
+        </el-table>
+        <el-pagination
+            :current-page="currentPage"
+            :page-size="pageSize"
+            :page-count="pagination[pageCountKey]"
+            :total="pagination[totalKey]"
+            @size-change="handlePaginationSizeChange"
+            @current-change="handlePaginationCurrentChange"
+            @prev-click="handlePaginationPrevClick"
+            @next-click="handlePaginationNextClick"
+        />
+    </div>
 </template>
 <script>
-import { fileTypes, allFileTypes, accept as acceptTypes } from '@/business/platform/file/constants/fileTypes'
-import { queryPageList } from '@/api/platform/file/attachment'
-import ActionUtils from '@/utils/action'
-export default {
-  props: {
-    height: String,
-    load: Boolean,
-    multiple: Boolean,
-    fileSize: { // 上传尺寸
-      type: Number
-    },
-    value: [Object, Array],
-    limit: {
-      type: Number
-    },
-    accept: String
-  },
-  data() {
-    return {
-      listData: [],
-      pagination: {},
-      sorts: {},
-      selectionRadio: '',
-      pkKey: 'id',
-      currentPage: 0,
-      pageSizes: [10, 20, 50, 100],
-      pageSize: 20,
-      totalKey: 'totalCount',
-      pageKey: 'page',
-      pageCountKey: 'totalPages',
-      selectionRow: true,
-      format: true,
-      form: {
-        name: ''
-      },
-      fileList: [],
-      multipleSelection: [],
-      targetExt: false,
-      fileTypes: fileTypes,
-      allFileTypes: allFileTypes,
-      acceptTypes: acceptTypes
-    }
-  },
-  computed: {
-    selectionType() {
-      return this.multiple ? 'checkbox' : 'radio'
-    }
-  },
-  watch: {
-    load: {
-      handler() {
-        this.loadData()
-      },
-      immediate: true
-    },
-    selectionRadio(val, oldVal) {
-      if (this.$utils.isNotEmpty(val)) {
-        this.$emit('callback', this.listData.find((data) => {
-          if (data.id === val) {
-            return data
-          }
-        }))
-      }
-    }
-  },
-  methods: {
-    getRowKey(row) {
-      return row.id
-    },
-    handleSelectionChange(val) {
-      if (this.limit && this.limit === 0) {
-        this.$message({
-          message: '上传个数不能为0',
-          type: 'warning'
-        })
-        return
-      }
-      var pass = true
-      val.forEach(i => {
-        if (this.$utils.isNotEmpty(this.fileSize) && this.fileSize < i.totalBytes) {
-          this.$message({
-            message: '上传文件的大小大于' + this.$utils.formatSize(this.fileSize),
-            type: 'warning'
-          })
-          pass = false
-          this.$refs.elTable.toggleRowSelection(i, pass)
-        }
+    import { fileTypes, allFileTypes, accept as acceptTypes } from '@/business/platform/file/constants/fileTypes'
+    import { queryPageList } from '@/api/platform/file/attachment'
+    import ActionUtils from '@/utils/action'
+    export default {
+        props: {
+            height: String,
+            load: Boolean,
+            multiple: Boolean,
+            fileSize: {
+                // 上传尺寸
+                type: Number
+            },
+            value: [Object, Array],
+            limit: {
+                type: Number
+            },
+            accept: String
+        },
+        data() {
+            return {
+                listData: [],
+                pagination: {},
+                sorts: {},
+                selectionRadio: '',
+                pkKey: 'id',
+                currentPage: 0,
+                pageSizes: [10, 20, 50, 100],
+                pageSize: 20,
+                totalKey: 'totalCount',
+                pageKey: 'page',
+                pageCountKey: 'totalPages',
+                selectionRow: true,
+                format: true,
+                form: {
+                    name: ''
+                },
+                fileList: [],
+                multipleSelection: [],
+                targetExt: false,
+                fileTypes: fileTypes,
+                allFileTypes: allFileTypes,
+                acceptTypes: acceptTypes
+            }
+        },
+        computed: {
+            selectionType() {
+                return this.multiple ? 'checkbox' : 'radio'
+            }
+        },
+        watch: {
+            load: {
+                handler() {
+                    this.loadData()
+                },
+                immediate: true
+            },
+            selectionRadio(val, oldVal) {
+                if (this.$utils.isNotEmpty(val)) {
+                    this.$emit('callback', this.listData.find(data => {
+                        if (data.id === val) {
+                            return data
+                        }
+                    }))
+                }
+            }
+        },
+        methods: {
+            getRowKey(row) {
+                return row.id
+            },
+            handleSelectionChange(val) {
+                if (this.limit && this.limit === 0) {
+                    this.$message({
+                        message: '上传个数不能为0',
+                        type: 'warning'
+                    })
+                    return
+                }
+                var pass = true
+                val.forEach(i => {
+                    if (this.$utils.isNotEmpty(this.fileSize) && this.fileSize < i.totalBytes) {
+                        this.$message({
+                            message: '上传文件的大小大于' + this.$utils.formatSize(this.fileSize),
+                            type: 'warning'
+                        })
+                        pass = false
+                        this.$refs.elTable.toggleRowSelection(i, pass)
+                    }
 
-        if (this.$utils.isNotEmpty(this.accept) && this.accept && !this.fileExtType({ name: `${i.fileName}.${i.ext}` })) {
-          this.$message.closeAll()
-          this.$message({
-            message: '不允许的文件类型',
-            type: 'warning'
-          })
-          pass = false
-          this.$refs.elTable.toggleRowSelection(i, pass)
-        }
-      })
-      if (!pass) {
-        return
-      }
-      this.multipleSelection = val
-      this.$emit('callback', val)
-    },
-    /**
-     * @description 行点击时触发的事件
-     */
-    handleRowClick(row, event, column) {
-      // 点击行,触发选中
-      if (this.$utils.isNotEmpty(this.fileSize) && this.fileSize < row.totalBytes) {
-        this.$message({
-          message: '上传文件的大小大于' + this.$utils.formatSize(this.fileSize),
-          type: 'warning'
-        })
-        return
-      }
-      if (this.$utils.isNotEmpty(this.accept) && this.accept && !this.fileExtType({ name: `${row.fileName}.${row.ext}` })) {
-        this.$message.closeAll()
-        this.$message({
-          message: '不允许的文件类型',
-          type: 'warning'
-        })
-        return false
-      }
-      if (this.selectionType === 'radio') {
-        this.selectionRadio = row[this.pkKey]
-      } else {
-        this.$refs.elTable.toggleRowSelection(row)
-      }
-      this.format = true
-      this.$emit('row-click', row, event, column)
-      this.$emit('format', this.format)
-    },
-    /**
-     * 文件类型的检测
-     */
-    fileExtType(file) {
-      const accept = this.accept
-      const acceptTypes = this.acceptTypes
-      const fileTypes = this.fileTypes
-      const arr = file.name.split('.')
-      const result = arr[arr.length - 1]
-      let type = ''
-      this.targetExt = false
-      for (const i in acceptTypes) {
-        if (acceptTypes[i] === accept) {
-          type = i
-        }
-      }
-      if (type !== '' && this.accept !== '*') {
-        // 现存的附件类型
-        const targetFileTypes = fileTypes[type]
-        this.targetExt = targetFileTypes.includes(result)
-      } else {
-        if (this.accept === '*') {
-        // 不限制
-          this.targetExt = true
-        } else {
-        // 自定义
-          const targetFileTypes = this.accept.split(',')
-          this.targetExt = targetFileTypes.includes('.' + result)
+                    if (this.$utils.isNotEmpty(this.accept) && this.accept && !this.fileExtType({ name: `${i.fileName}.${i.ext}` })) {
+                        this.$message.closeAll()
+                        this.$message({
+                            message: '不允许的文件类型',
+                            type: 'warning'
+                        })
+                        pass = false
+                        this.$refs.elTable.toggleRowSelection(i, pass)
+                    }
+                })
+                if (!pass) {
+                    return
+                }
+                this.multipleSelection = val
+                this.$emit('callback', val)
+            },
+            /**
+             * @description 行点击时触发的事件
+             */
+            handleRowClick(row, event, column) {
+                // 点击行,触发选中
+                if (this.$utils.isNotEmpty(this.fileSize) && this.fileSize < row.totalBytes) {
+                    this.$message({
+                        message: '上传文件的大小大于' + this.$utils.formatSize(this.fileSize),
+                        type: 'warning'
+                    })
+                    return
+                }
+
+                if (this.$utils.isNotEmpty(this.accept) && this.accept && !this.fileExtType({ name: `${row.fileName}.${row.ext}` })) {
+                    this.$message.closeAll()
+                    this.$message({
+                        message: '不允许的文件类型',
+                        type: 'warning'
+                    })
+                    return false
+                }
+                if (this.selectionType === 'radio') {
+                    this.selectionRadio = row[this.pkKey]
+                } else {
+                    this.$refs.elTable.toggleRowSelection(row)
+                }
+                this.format = true
+                this.$emit('row-click', row, event, column)
+                this.$emit('format', this.format)
+            },
+            /**
+             * 文件类型的检测
+             */
+            fileExtType(file) {
+                const accept = this.accept
+                const acceptTypes = this.acceptTypes
+                const fileTypes = this.fileTypes
+                const arr = file.name.split('.')
+                const result = arr[arr.length - 1]
+                let type = ''
+                this.targetExt = false
+                for (const i in acceptTypes) {
+                    if (acceptTypes[i] === accept) {
+                        type = i
+                    }
+                }
+                if (type !== '' && this.accept !== '*') {
+                    // 现存的附件类型
+                    const targetFileTypes = fileTypes[type]
+                    this.targetExt = targetFileTypes.includes(result)
+                } else {
+                    if (this.accept === '*') {
+                        // 不限制
+                        this.targetExt = true
+                    } else {
+                        // 自定义
+                        const targetFileTypes = this.accept.split(',')
+                        this.targetExt = targetFileTypes.includes('.' + result)
+                    }
+                }
+                return this.targetExt
+            },
+            /**
+             * @description 单选点击时触发的事件[阻止冒泡后单选值补充]
+             */
+            changeRowRadio(row) {
+                if (this.$utils.isNotEmpty(this.fileSize) && this.fileSize < row.totalBytes) {
+                    this.$message({
+                        message: '上传文件的大小大于' + this.$utils.formatSize(this.fileSize),
+                        type: 'warning'
+                    })
+                    return
+                }
+                if (this.$utils.isNotEmpty(this.accept) && this.accept && !this.fileExtType({ name: `${row.fileName}.${row.ext}` })) {
+                    this.$message.closeAll()
+                    this.$message({
+                        message: '不允许的文件类型',
+                        type: 'warning'
+                    })
+                    return
+                }
+                this.selectionRadio = row[this.pkKey]
+            },
+            toggleRowSelection(row, selected) {
+                if (this.selectionType === 'radio') {
+                    this.selectionRadio = row ? row[this.pkKey] : ''
+                } else {
+                    this.$refs.elTable.toggleRowSelection(row, selected)
+                }
+            },
+            loadData() {
+                this.loading = true
+                queryPageList(this.getSearcFormData()).then(response => {
+                    ActionUtils.handleListData(this, response.data)
+                    this.loading = false
+                }).catch(() => {
+                    this.loading = false
+                })
+            },
+            getSearcFormData() {
+                return ActionUtils.formatParams(
+                    {
+                        'Q^FILE_NAME_^SL': this.form.name
+                    },
+                    this.pagination,
+                    this.sorts
+                )
+            },
+            onSearch() {
+                this.loadData()
+            },
+            /**
+             * @description 每页条数改变
+             */
+            handlePaginationSizeChange(pageSize) {
+                this.handlePaginationChange({ pageSize: pageSize })
+            },
+            /**
+             * @description 当前页码改变
+             */
+            handlePaginationCurrentChange(currentPage) {
+                this.handlePaginationChange({ currentPage: currentPage })
+            },
+            /**
+             * @description 上一页
+             */
+            handlePaginationPrevClick(currentPage) {
+                this.handlePaginationChange({ currentPage: currentPage })
+            },
+            /**
+             * @description 下一页
+             */
+            handlePaginationNextClick(currentPage) {
+                this.handlePaginationChange({ currentPage: currentPage })
+            },
+            /**
+             * 处理分页事件
+             */
+            handlePaginationChange({ pageSize, currentPage }) {
+                ActionUtils.setPagination(this.pagination, {
+                    limit: pageSize || this.pageSize,
+                    page: currentPage || this.currentPage
+                })
+                this.loadData()
+            },
+            /**
+             * @description 组件属性默认值
+             */
+            handleAttribute(attribute, defaultValue) {
+                if (attribute === false || attribute === 0 || attribute === '') {
+                    return attribute
+                }
+                return attribute || defaultValue
+            }
         }
-      }
-      return this.targetExt
-    },
-    /**
-     * @description 单选点击时触发的事件[阻止冒泡后单选值补充]
-     */
-    changeRowRadio(row) {
-      if (this.$utils.isNotEmpty(this.fileSize) && this.fileSize < row.totalBytes) {
-        this.$message({
-          message: '上传文件的大小大于' + this.$utils.formatSize(this.fileSize),
-          type: 'warning'
-        })
-        return
-      }
-      if (this.$utils.isNotEmpty(this.accept) && this.accept && !this.fileExtType({ name: `${row.fileName}.${row.ext}` })) {
-        this.$message.closeAll()
-        this.$message({
-          message: '不允许的文件类型',
-          type: 'warning'
-        })
-        return
-      }
-      this.selectionRadio = row[this.pkKey]
-    },
-    toggleRowSelection(row, selected) {
-      if (this.selectionType === 'radio') {
-        this.selectionRadio = row ? row[this.pkKey] : ''
-      } else {
-        this.$refs.elTable.toggleRowSelection(row, selected)
-      }
-    },
-    loadData() {
-      this.loading = true
-      queryPageList(this.getSearcFormData()).then(response => {
-        ActionUtils.handleListData(this, response.data)
-        this.loading = false
-      }).catch(() => {
-        this.loading = false
-      })
-    },
-    getSearcFormData() {
-      return ActionUtils.formatParams(
-        {
-          'Q^FILE_NAME_^SL': this.form.name
-        },
-        this.pagination,
-        this.sorts)
-    },
-    onSearch() {
-      this.loadData()
-    },
-    /**
-     * @description 每页条数改变
-     */
-    handlePaginationSizeChange(pageSize) {
-      this.handlePaginationChange({ pageSize: pageSize })
-    },
-    /**
-     * @description 当前页码改变
-     */
-    handlePaginationCurrentChange(currentPage) {
-      this.handlePaginationChange({ currentPage: currentPage })
-    },
-    /**
-     * @description 上一页
-     */
-    handlePaginationPrevClick(currentPage) {
-      this.handlePaginationChange({ currentPage: currentPage })
-    },
-    /**
-     * @description 下一页
-     */
-    handlePaginationNextClick(currentPage) {
-      this.handlePaginationChange({ currentPage: currentPage })
-    },
-    /**
-     * 处理分页事件
-     */
-    handlePaginationChange({ pageSize, currentPage }) {
-      ActionUtils.setPagination(this.pagination, {
-        limit: pageSize || this.pageSize,
-        page: currentPage || this.currentPage
-      })
-      this.loadData()
-    },
-    /**
-     * @description 组件属性默认值
-     */
-    handleAttribute(attribute, defaultValue) {
-      if (attribute === false || attribute === 0 || attribute === '') {
-        return attribute
-      }
-      return attribute || defaultValue
     }
-  }
-
-}
 </script>

+ 2 - 2
src/views/platform/bpmn/bpmInstHis/record/CMA.vue

@@ -9,9 +9,9 @@
         data () {
             return {
                 info: {
-                    title: 'CNAS&CMA检测档案',
+                    title: 'CMA检测档案',
                     reportPath: '43罗湖/LHXBJY 检测报告',
-                    type: 'CNAS&CMA'
+                    type: 'CMA'
                 }
             }
         }

+ 61 - 22
src/views/platform/bpmn/bpmInstHis/record/component/testingRecord.vue

@@ -5,12 +5,23 @@
             <template v-for="(item, index) in searchList">
                 <span class="label">{{item.label}}</span>
                 <el-input
+                    v-if="item.value !== 'sampleTime'"
                     v-model="searchParam[item.value]"
                     class="input"
                     placeholder="请输入内容"
                     clearable
                     @keyup.enter.native="search"
                 ></el-input>
+                <el-date-picker
+                    v-else
+                    v-model="searchParam[item.value]"
+                    type="daterange"
+                    unlink-panels
+                    range-separator="-"
+                    start-placeholder="开始日期"
+                    end-placeholder="结束日期"
+                    style="width: 220px;"
+                ></el-date-picker>
             </template>
             <el-button class="btn" type="primary" @click="search">
                 <i class="ibps-icon-search"></i>查询
@@ -26,31 +37,25 @@
                 header-cell-class-name="table-header"
             >
                 <!-- <el-table-column type="selection" width="55"></el-table-column> -->
-                <!-- <el-table-column prop="year" label="年份" width="80">
-                    <template slot-scope="scope">{{ scope.row.jian_ce_kai_shi_s | getYear }}</template>
-                </el-table-column> -->
                 <el-table-column prop="he_tong_id_" label="合同编号" width="100">
                     <template slot-scope="scope">{{ scope.row.he_tong_id_ | getID(contractList) }}</template>
                 </el-table-column>
-                <el-table-column prop="bao_gao_bian_hao_" label="报告编号" width="150"></el-table-column>
-                <el-table-column prop="jian_ce_kai_shi_s" label="检测时间" width="100">
-                    <template slot-scope="scope">{{ scope.row.jian_ce_kai_shi_s.slice(0, 10) }}</template>
-                </el-table-column>
-                <el-table-column prop="wei_tuo_id_" label="检测委托单号" width="150">
+                <el-table-column prop="wei_tuo_id_" label="委托单号" width="110">
                     <template slot-scope="scope">{{ scope.row.wei_tuo_id_ | getID(trustList) }}</template>
                 </el-table-column>
-                <el-table-column prop="wei_tuo_fang_" label="委托单位"></el-table-column>
-                <el-table-column prop="wan_cheng_shi_jia" label="委托日期" width="100"></el-table-column>
-                <el-table-column prop="yang_pin_bian_hao" label="样品编号" width="150"></el-table-column>
+                <el-table-column prop="bao_gao_bian_hao_" label="报告编号" width="110"></el-table-column>
+                <!-- <el-table-column prop="wei_tuo_fang_" label="委托单位"></el-table-column> -->
+                <!-- <el-table-column prop="wan_cheng_shi_jia" label="委托日期" width="100"></el-table-column> -->
+                <el-table-column prop="yang_pin_bian_hao" label="样品编号" width="110"></el-table-column>
                 <el-table-column prop="yang_pin_ming_che" label="样品名称" width="150"></el-table-column>
-                <!-- <el-table-column prop="lian_xi_ren_" label="联系人"> </el-table-column>
-                <el-table-column prop="lian_xi_dian_hua_" label="联系电话"></el-table-column>
-                <el-table-column prop="bao_gao_lei_bie_" label="类别">
-                    <template slot-scope="scope">
-                        {{ scope.row.bao_gao_lei_bie_.toUpperCase() }}
-                    </template>
-                </el-table-column> -->
-                <el-table-column label="操作" align="left">
+                <el-table-column prop="song_jian_" label="送检单位" width="150"></el-table-column>
+                <el-table-column prop="song_jian_shi_jia" label="送检日期" width="100"></el-table-column>
+                <el-table-column label="检测时间" width="100">
+                    <template slot-scope="scope">{{ getTestTime(scope.row) }}</template>
+                </el-table-column>
+                <el-table-column prop="gai_zhang_jian_pd" label="检测项目"></el-table-column>
+
+                <el-table-column label="操作" align="left" width="100">
                     <template slot-scope="scope">
                         <el-popover placement="left" width="200" trigger="click">
                             <div slot="reference" class="more">
@@ -156,6 +161,14 @@
         {
             label: '样品名称',
             value: 'sampleName'
+        },
+        {
+            label: '检测项目',
+            value: 'projectName'
+        },
+        {
+            label: '送检日期',
+            value: 'sampleTime'
         }
     ]
     let reportList = [
@@ -237,7 +250,9 @@
                 searchParam: {
                     report: '',
                     sampleId: '',
-                    sampleName: ''
+                    sampleName: '',
+                    projectName: '',
+                    sampleTime: ''
                 },
                 tableData: [],
                 testingList: [],
@@ -298,6 +313,17 @@
                     })
                 })
             },
+            getTestTime ({jian_ce_kai_shi_s, jian_ce_jie_shu_s}) {
+                const start = jian_ce_kai_shi_s ? jian_ce_kai_shi_s.slice(0, 10) : ''
+                const end = jian_ce_jie_shu_s ? jian_ce_jie_shu_s.slice(0, 10) : ''
+                if (!start && !end) {
+                    return ''
+                }
+                if (!end || start === end) {
+                    return start
+                }
+                return `${start}至${end}`
+            },
             // 获取检测项目数据
             getTesting (row) {
                 const { wei_tuo_id_, yang_pin_bian_hao, xiu_gai_bao_gao_b } = row
@@ -328,13 +354,26 @@
             consult (data) {
                 this.alertReport(testingPath[data.number], data.id)
             },
+            timeFormat (time) {
+                return new Date(time.getTime() + 28800000).toJSON().slice(0, 10)
+            },
             // 组装查询SQL
             search () {
-                const { report, sampleId, sampleName } = this.searchParam
+                const { report, sampleId, sampleName, projectName, sampleTime } = this.searchParam
+                const start = sampleTime && sampleTime.length ? this.timeFormat(sampleTime[0]) : ''
+                const end = sampleTime && sampleTime.length ? this.timeFormat(sampleTime[1]) : ''
+                var t = ''
+                if (start === end) {
+                    t = `like '%${start}%'`
+                } else {
+                    t = `between '${start}' and '${end}'`
+                }
                 const paramsList = {
                     report: ` and bao_gao_bian_hao_ like '%${report}%'`,
                     sampleId: ` and yang_pin_bian_hao like '%${sampleId}%'`,
-                    sampleName: ` and yang_pin_ming_che like '%${sampleName}%'`
+                    sampleName: ` and yang_pin_ming_che like '%${sampleName}%'`,
+                    projectName: ` and gai_zhang_jian_pd like '%${projectName}%'`,
+                    sampleTime: ` and song_jian_shi_jia ${t}`
                 }
                 let params = ''
                 Object.keys(this.searchParam).forEach(item => {