Crunchy
2025-04-29 e5454b769d44a34af423bf87ac8a740bf8c20341
src/views/structural/premises/index.vue
@@ -5,15 +5,15 @@
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
          <el-form-item label="实验室名称" prop="laboratoryName">
            <el-input size="small" placeholder="请输入" clearable v-model="queryParams.laboratoryName"
                      @keyup.enter.native="refreshTable"></el-input>
              @keyup.enter.native="refreshTable"></el-input>
          </el-form-item>
          <el-form-item label="实验室编码" prop="laboratoryNumber">
            <el-input size="small" placeholder="请输入" clearable v-model="queryParams.laboratoryNumber"
                      @keyup.enter.native="refreshTable"></el-input>
              @keyup.enter.native="refreshTable"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="refreshTable">查 询</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="refresh">重 置</el-button>
            <el-button type="primary" size="mini" @click="refreshTable">查询</el-button>
            <el-button size="mini" @click="refresh">重置</el-button>
          </el-form-item>
        </el-form>
      </div>
@@ -22,15 +22,13 @@
      </div>
    </div>
    <div class="table">
      <lims-table :tableData="tableData" :column="column"
                  :height="'calc(100vh - 250px)'"
                  @pagination="pagination"
                  :page="page" :tableLoading="tableLoading"></lims-table>
      <lims-table :tableData="tableData" :column="column" :height="'calc(100vh - 250px)'" @pagination="pagination"
        :page="page" :tableLoading="tableLoading"></lims-table>
    </div>
<!--    新增实验室-->
    <!--    新增实验室-->
    <el-dialog :title="formTitle" :visible.sync="addDia" width="450px">
      <el-form ref="laboratoryForm" :model="laboratoryForm" :rules="userRules"
               label-position="right" label-width="100px">
      <el-form ref="laboratoryForm" :model="laboratoryForm" :rules="userRules" label-position="right"
        label-width="100px">
        <el-form-item label="实验室名称" prop="laboratoryName">
          <el-input v-model="laboratoryForm.laboratoryName" size="small" clearable></el-input>
        </el-form-item>
@@ -51,52 +49,36 @@
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
            <el-button @click="reset">取 消</el-button>
            <el-button type="primary" @click="customAdd" :loading="loading">确 定</el-button>
         </span>
        <el-button @click="reset">取 消</el-button>
        <el-button type="primary" @click="customAdd" :loading="loading">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog title="印章管理" :visible.sync="fileVisible" width="60vw">
      <div class="btns">
        <el-button size="medium" type="primary" @click="openUpload">更新印章</el-button>
      </div>
      <lims-table :tableData="fileComponentData" :column="fileComponentDataColumn"
                  @pagination="fileComponentPagination" height="500px"
                  :page="fileComponentPage" :tableLoading="fileComponentTableLoading"></lims-table>
      <lims-table :tableData="fileComponentData" :column="fileComponentDataColumn" @pagination="fileComponentPagination"
        height="500px" :page="fileComponentPage" :tableLoading="fileComponentTableLoading"></lims-table>
    </el-dialog>
    <el-dialog title="更新印章" :visible.sync="upFileVisible" width="400px">
      <el-form ref="dataForm" :model="dataForm" :rules="dataFormRules"
               label-position="right" label-width="80px">
      <el-form ref="dataForm" :model="dataForm" :rules="dataFormRules" label-position="right" label-width="80px">
        <el-form-item label="印章类型" prop="type">
          <el-cascader
            v-model="dataForm.type"
            :options="options"
            :show-all-levels="false"
            :props="props"
            placeholder="请选择" size="small"
            style="width:100%"
            collapse-tags
            clearable></el-cascader>
          <el-cascader v-model="dataForm.type" :options="options" :show-all-levels="false" :props="props"
            placeholder="请选择" size="small" style="width:100%" collapse-tags clearable></el-cascader>
        </el-form-item>
        <el-form-item label="印章图片" prop="address">
          <el-upload
            class="avatar-uploader"
            :action="action"
            :headers="headers"
            accept='image/jpg,image/jpeg,image/png'
            :show-file-list="false"
            :on-success="handleSuccess"
            :on-change="beforeUpload"
            ref="upload"
            :on-error="onError">
            <img v-if="dataForm.address" :src="javaApi+'/img/'+dataForm.address" class="avatar" >
          <el-upload class="avatar-uploader" :action="action" :headers="uploadHeader"
            accept='image/jpg,image/jpeg,image/png' :show-file-list="false" :on-success="handleSuccess"
            :on-change="beforeUpload" ref="upload" :on-error="onError">
            <img v-if="dataForm.address" :src="javaApi + '/img/' + dataForm.address" class="avatar">
            <i v-else class="el-icon-plus avatar-uploader-icon"></i>
          </el-upload>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
            <el-button @click="upFileVisible = false">取 消</el-button>
            <el-button type="primary" @click="confirmConnect" :loading="loading">确 定</el-button>
         </span>
        <el-button @click="upFileVisible = false">取 消</el-button>
        <el-button type="primary" @click="confirmConnect" :loading="loading">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
@@ -111,21 +93,15 @@
  selectSeal,
  upParameter
} from "@/api/structural/laboratoryScope";
import {getCertificationDetail} from "@/api/structural/laboratory";
import { getCertificationDetail } from "@/api/structural/laboratory";
export default {
  components: {
    limsTable
  },
  computed: {
    headers() {
      return {
        'token': sessionStorage.getItem('token')
      }
    },
    action() {
      return this.javaApi
      return this.javaApi + '/deviceScope/uploadFile'
    }
  },
  data() {
@@ -137,19 +113,17 @@
      tableData: [],
      tableLoading: false,
      column: [
        {label: '实验室名称', prop: 'laboratoryName'},
        {label: '场所编码', prop: 'laboratoryNumber'},
        {label: '实验室代号', prop: 'laboratoryCode'},
        {label: '负责人', prop: 'head'},
        {label: '负责人电话', prop: 'phoneNumber'},
        {label: '地址', prop: 'address'},
        {label: '创建人', prop: 'createUserName'},
        {label: '创建时间', prop: 'createTime'},
        { label: '实验室名称', prop: 'laboratoryName' },
        { label: '场所编码', prop: 'laboratoryNumber' },
        { label: '实验室代号', prop: 'laboratoryCode' },
        { label: '负责人', prop: 'head' },
        { label: '负责人电话', prop: 'phoneNumber' },
        { label: '地址', prop: 'address' },
        { label: '创建人', prop: 'createUserName' },
        { label: '创建时间', prop: 'createTime' },
        {
          dataType: 'action',
          fixed: 'right',
          label: '操作',
          width: '180px',
          operation: [
            {
              name: '编辑',
@@ -176,9 +150,9 @@
        }
      ],
      page: {
        total:0,
        size:10,
        current:1
        total: 0,
        size: 10,
        current: 1
      },
      addDia: false,
      formTitle: '',
@@ -196,43 +170,43 @@
      fileComponentTableLoading: false,
      fileComponentData: [],
      fileComponentDataColumn: [
        {label: '实验室名称', prop: 'laboratoryName'},
        {label: '印章图片', prop: 'address', dataType: 'image'},
        {label: '印章类型', prop: 'type'},
        { label: '实验室名称', prop: 'laboratoryName' },
        { label: '印章图片', prop: 'address', dataType: 'image' },
        { label: '印章类型', prop: 'type' },
      ],
      fileComponentPage: {
        total:0,
        size:10,
        current:1,
        total: 0,
        size: 10,
        current: 1,
        layout: 'total, prev, pager, next'
      },
      fileVisible:false,
      upFileVisible:false,
      loading:false,
      dataForm:{
        type:'',
        address:'',
      fileVisible: false,
      upFileVisible: false,
      loading: false,
      dataForm: {
        type: '',
        address: '',
      },
      dataFormRules: {
        type: [{ required: true, message: '请选择印章类型', trigger: 'change' }],
        address: [{ required: false, message: '请上传图片', trigger: 'change' }],
      },
      props: { multiple: false,emitPath:false,},
      options:[
      props: { multiple: false, emitPath: false, },
      options: [
        {
          value:'实验室资质',
          label:'实验室资质',
          children:[]
          value: '实验室资质',
          label: '实验室资质',
          children: []
        },
        {
          value:'委托报告',
          label:'委托报告',
          children:null
          value: '委托报告',
          label: '委托报告',
          children: null
        },
        {
          value:'进厂报告',
          label:'进厂报告',
          children:null
          value: '进厂报告',
          label: '进厂报告',
          children: null
        },
      ],
    }
@@ -243,7 +217,7 @@
  methods: {
    refreshTable() {
      this.tableLoading = true
      selectItemParameter({...this.page, ...this.queryParams}).then(res => {
      selectItemParameter({ ...this.page, ...this.queryParams }).then(res => {
        this.tableLoading = false
        if (res.code === 200) {
          this.tableData = res.data.records
@@ -259,7 +233,7 @@
      this.refreshTable()
    },
    // 分页切换
    pagination (page) {
    pagination(page) {
      this.page.size = page.limit
      this.refreshTable()
    },
@@ -300,34 +274,32 @@
        }
      })
    },
    reset () {
    reset() {
      this.resetForm('laboratoryForm')
      this.addDia = false
    },
    // 删除实验室
    delete (row) {
    delete(row) {
      this.$confirm('是否删除当前数据?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        delParameter({id: row.id}).then(res => {
        delParameter({ id: row.id }).then(res => {
          this.$message.success('删除成功')
          this.refreshTable()
        }).catch(e => {
          this.$message.error('删除失败')
        })
      }).catch(() => {})
      }).catch(() => { })
    },
    // 打开印章管理弹框
    fileManagement(row){
    fileManagement(row) {
      this.fileVisible = true;
      this.fileComponentTableLoading = true
      this.currentRow = row
      this.getFileComponentList()
    },
    getFileComponentList () {
      selectSeal({id: this.currentRow.id, ...this.fileComponentPage}).then(res => {
    getFileComponentList() {
      selectSeal({ id: this.currentRow.id, ...this.fileComponentPage }).then(res => {
        this.fileComponentTableLoading = false
        if (res.code === 200) {
          this.fileComponentData = res.data.records
@@ -337,19 +309,19 @@
        this.fileComponentTableLoading = false
      })
    },
    fileComponentPagination (page) {
    fileComponentPagination(page) {
      this.fileComponentPage.size = page.limit
      this.getFileComponentList()
    },
    // 打开更新印章弹框
    openUpload(){
    openUpload() {
      this.dataForm.type = '';
      this.dataForm.address = '';
      this.upFileVisible = true;
      this.getCertificationOperation()
    },
    // 查询印章类型
    getCertificationOperation(){
    getCertificationOperation() {
      const params = {
        current: -1,
        size: -1,
@@ -363,11 +335,11 @@
      })
    },
    // 提交更新印章
    confirmConnect(){
    confirmConnect() {
      this.$refs['dataForm'].validate((valid) => {
        if (valid) {
          this.loading = true;
          addSeal({labId:this.currentRow.id, ...this.dataForm}).then(res => {
          addSeal({ labId: this.currentRow.id, ...this.dataForm }).then(res => {
            this.loading = false;
            this.getFileComponentList()
            this.upFileVisible = false;
@@ -375,12 +347,12 @@
        }
      })
    },
    handleSuccess(response,){
    handleSuccess(response,) {
      if (response.code === 200) {
        this.dataForm.address = response.data.url
      }
    },
    beforeUpload(file,type) {
    beforeUpload(file, type) {
      if (file.size > 1024 * 1024 * 10) {
        this.$message.error('上传文件不超过10M');
        this.$refs.upload.clearFiles()
@@ -389,7 +361,7 @@
        return true;
      }
    },
    onError(err, file, fileList,type) {
    onError(err, file, fileList, type) {
      this.$message.error('上传失败')
      this.$refs.upload.clearFiles()
    },
@@ -402,13 +374,16 @@
  display: flex;
  justify-content: space-between;
}
.btns{
.btns {
  text-align: right;
  margin-bottom: 10px;
}
::v-deep .el-dialog__body {
  padding-top: 8px !important;
}
.avatar-uploader ::v-deep .el-upload {
  border: 1px dashed #666666;
  border-radius: 6px;
@@ -416,9 +391,11 @@
  position: relative;
  overflow: hidden;
}
.avatar-uploader ::v-deep .el-upload:hover {
  border-color: #409EFF;
}
.avatar-uploader-icon {
  font-size: 20px;
  color: #8c939d;
@@ -427,6 +404,7 @@
  line-height: 90px;
  text-align: center;
}
.avatar {
  width: 90px;
  height: 90px;