licp
2024-04-19 e04fbe73f7785155bffe3db30a7ead37f9200f06
src/components/view/a7-standard-method.vue
@@ -1,175 +1,251 @@
<style scoped>
   .title {
      height: 60px;
      line-height: 60px;
   }
  .title {
    height: 60px;
    line-height: 60px;
  }
   .search {
      background-color: #fff;
      height: 80px;
      display: flex;
      align-items: center;
   }
  .search {
    background-color: #fff;
    height: 80px;
    display: flex;
    align-items: center;
  }
   .search_thing {
      width: 350px;
      display: flex;
      align-items: center;
   }
  .search_thing {
    width: 350px;
    display: flex;
    align-items: center;
  }
   .search_label {
      width: 110px;
      font-size: 14px;
      text-align: right;
   }
  .search_label {
    width: 110px;
    font-size: 14px;
    text-align: right;
  }
   .search_input {
      width: calc(100% - 110px);
   }
  .search_input {
    width: calc(100% - 110px);
  }
   .table {
      margin-top: 10px;
      background-color: #fff;
      width: calc(100% - 40px);
      height: calc(100% - 60px - 80px - 10px - 40px);
      padding: 20px;
   }
  .table {
    margin-top: 10px;
    background-color: #fff;
    width: calc(100% - 40px);
    height: calc(100% - 60px - 80px - 10px - 40px);
    padding: 20px;
  }
</style>
<template>
   <div class="standard_method">
      <div>
         <el-row class="title">
            <el-col :span="12" style="padding-left: 20px;">标准方法</el-col>
            <el-col :span="12" style="text-align: right;">
               <el-button size="medium" type="primary" @click="openAdd" v-if="addPower">新增</el-button>
            </el-col>
         </el-row>
      </div>
      <div class="search">
         <div class="search_thing">
            <div class="search_label">标准编号:</div>
            <div class="search_input"><el-input size="small" placeholder="请输入" clearable
                  v-model="componentData.entity.code" @keyup.enter.native="refreshTable()"></el-input></div>
         </div>
         <div class="search_thing">
            <div class="search_label">标准名称:</div>
            <div class="search_input"><el-input size="small" placeholder="请输入" clearable
                  v-model="componentData.entity.name" @keyup.enter.native="refreshTable()"></el-input></div>
         </div>
         <div class="search_thing" style="padding-left: 30px;">
            <el-button size="small" @click="refresh()">重 置</el-button>
            <el-button size="small" type="primary" @click="refreshTable()">查 询</el-button>
         </div>
      </div>
      <div class="table">
         <ValueTable ref="ValueTable" :url="$api.standardMethod.selectStandardMethodList"
         :delUrl="$api.standardMethod.delStandardMethod" :upUrl="$api.standardMethod.upStandardMethod" :componentData="componentData" :key="upIndex"/>
      </div>
   </div>
  <div class="standard_method">
    <div>
      <el-row class="title">
        <el-col :span="12" style="padding-left: 20px;">标准方法</el-col>
        <el-col :span="12" style="text-align: right;">
          <el-button size="medium" type="primary" @click="openAdd" v-if="addPower">新增</el-button>
        </el-col>
      </el-row>
    </div>
    <div class="search">
      <div class="search_thing">
        <div class="search_label">标准编号:</div>
        <div class="search_input"><el-input size="small" placeholder="请输入" clearable v-model="componentData.entity.code"
            @keyup.enter.native="refreshTable()"></el-input></div>
      </div>
      <div class="search_thing">
        <div class="search_label">标准名称:</div>
        <div class="search_input"><el-input size="small" placeholder="请输入" clearable v-model="componentData.entity.name"
            @keyup.enter.native="refreshTable()"></el-input></div>
      </div>
      <div class="search_thing" style="padding-left: 30px;">
        <el-button size="small" @click="refresh()">重 置</el-button>
        <el-button size="small" type="primary" @click="refreshTable()">查 询</el-button>
      </div>
    </div>
    <div class="table">
      <ValueTable ref="ValueTable" :url="$api.standardMethod.selectStandardMethodList"
        :delUrl="$api.standardMethod.delStandardMethod" :upUrl="$api.standardMethod.upStandardMethod"
        :componentData="componentData" :key="upIndex" />
    </div>
  </div>
</template>
<script>
   import ValueTable from '../tool/value-table.vue'
   export default {
      components: {
         ValueTable
      },
      data() {
         return {
            componentData: {
               entity: {
                  code: null,
                  name: null,
                  orderBy: {
                     field: 'id',
                     order: 'asc'
                  }
               },
               isIndex: true,
               showSelect: false,
               select: true,
               do: [{
                  id: 'update',
                  font: '编辑',
                  type: 'text',
                  method: 'doDiy',
                  field:['sampleType','createUserName','updateUserName','检验对象=structureTestObjectId']
               },{
                  id: 'delete',
                  font: '删除',
                  type: 'text',
                  method: 'doDiy'
               }],
               tagField: {
                  structureTestObjectId:{select: []}
               },
               selectField: {
                  structureTestObjectId:{select: []}
               },
               requiredAdd:['code','name','structureTestObjectId'],
               requiredUp:['code','name','structureTestObjectId']
            },
            entityCopy: {},
            upIndex: 0,
            addDia: false,
            addPower: true
         }
      },
      mounted() {
         this.entityCopy = this.HaveJson(this.componentData.entity)
         this.getPower()
         this.selectTestObjectByName()
      },
      methods: {
         refreshTable() {
            this.$refs['ValueTable'].selectList()
         },
         refresh() {
            this.componentData.entity = this.HaveJson(this.entityCopy)
            this.upIndex++
         },
         // 权限分配
         getPower(){
            let power = JSON.parse(sessionStorage.getItem('power'))
            let up = false
            let del = false
            let add = false
            for (var i = 0; i < power.length; i++) {
               if(power[i].menuMethod=='addStandardMethod'){
                  add = true
               }
               if(power[i].menuMethod=='delStandardMethod'){
                  del = true
               }
               if(power[i].menuMethod=='upStandardMethod'){
                  up = true
               }
            }
            if(!del){
               this.componentData.do.splice(1, 1)
            }
            if(!up){
               this.componentData.do.splice(0, 1)
            }
            this.addPower = add
         },
         openAdd(){
            this.$refs.ValueTable.openAddDia(this.$api.standardMethod.addStandardMethod);
         },
         selectTestObjectByName() {
            this.$axios.get(this.$api.capacityScope.selectTestObjectByName).then(res => {
               let data = []
               res.data.forEach(a => {
                  data.push({
                     label: a.specimenName,
                     value: a.id
                  })
               })
               this.componentData.selectField.structureTestObjectId.select = data
               this.componentData.tagField.structureTestObjectId.select = data
            })
         },
      }
   }
</script>
  import ValueTable from '../tool/value-table.vue'
  export default {
    components: {
      ValueTable
    },
    data() {
      return {
        componentData: {
          entity: {
            code: null,
            name: null,
            orderBy: {
              field: 'id',
              order: 'asc'
            }
          },
          isIndex: true,
          showSelect: false,
          select: true,
          do: [{
            id: 'update',
            font: '编辑',
            type: 'text',
            method: 'doDiy',
            field: ['sampleType', 'createUserName', 'updateUserName', '检验对象=structureTestObjectId']
          }, {
            id: 'delete',
            font: '删除',
            type: 'text',
            method: 'doDiy'
          }],
          tagField: {
            structureTestObjectId: {
              select: []
            },
            isProduct: {
              select: [{
                value: 0,
                type: 'info',
                label: '否'
              }, {
                value: 1,
                label: '是'
              }]
            },
            isUse: {
              select: [{
                value: 0,
                type: 'info',
                label: '否'
              }, {
                value: 1,
                label: '是'
              }]
            },
            qualificationId:{
              select: []
            }
          },
          selectField: {
            structureTestObjectId: {
              select: []
            },
            isProduct: {
              select: [{
                value: 0,
                type: 'info',
                label: '否'
              }, {
                value: 1,
                label: '是'
              }]
            },
            isUse: {
              select: [{
                value: 0,
                type: 'info',
                label: '否'
              }, {
                value: 1,
                label: '是'
              }]
            },
            qualificationId:{
              select: []
            }
          },
          requiredAdd: ['code', 'name', 'structureTestObjectId', 'isProduct','isUse','nameEn'],
          requiredUp: ['code', 'name', 'structureTestObjectId', 'isProduct','isUse','nameEn']
        },
        entityCopy: {},
        upIndex: 0,
        addDia: false,
        addPower: true
      }
    },
    mounted() {
      this.entityCopy = this.HaveJson(this.componentData.entity)
      this.getPower()
      this.selectTestObjectByName()
      this.getQualificationList()
    },
    methods: {
      refreshTable() {
        this.$refs['ValueTable'].selectList()
      },
      refresh() {
        this.componentData.entity = this.HaveJson(this.entityCopy)
        this.upIndex++
      },
      // 权限分配
      getPower() {
        let power = JSON.parse(sessionStorage.getItem('power'))
        let up = false
        let del = false
        let add = false
        for (var i = 0; i < power.length; i++) {
          if (power[i].menuMethod == 'addStandardMethod') {
            add = true
          }
          if (power[i].menuMethod == 'delStandardMethod') {
            del = true
          }
          if (power[i].menuMethod == 'upStandardMethod') {
            up = true
          }
        }
        if (!del) {
          this.componentData.do.splice(1, 1)
        }
        if (!up) {
          this.componentData.do.splice(0, 1)
        }
        this.addPower = add
      },
      openAdd() {
        this.$refs.ValueTable.openAddDia(this.$api.standardMethod.addStandardMethod);
      },
      selectTestObjectByName() {
        this.$axios.get(this.$api.capacityScope.selectTestObjectByName).then(res => {
          let data = []
          res.data.forEach(a => {
            data.push({
              label: a.specimenName,
              value: a.id
            })
          })
          this.componentData.selectField.structureTestObjectId.select = data
          this.componentData.tagField.structureTestObjectId.select = data
        })
      },
      getQualificationList(){
        this.$axios.post(this.$api.certification.getCertificationDetail,{
            page: {
              current: -1,
              size: -1
            },
            entity:{
              name: null,
        }}, {
            headers: {
              'Content-Type': 'application/json'
            }
          }).then(res => {
            if(res.code==200){
              let list = res.data.body.records.map(item => {
                item.label = item.name
                item.value = item.id
                return item
              });
              this.componentData.selectField.qualificationId.select = list
              this.componentData.tagField.qualificationId.select = list
            }
          })
      }
    }
  }
</script>