licp
2024-09-14 a28a7e0dc8992c39004ad0b34d2624390024f3af
src/components/do/b1-report-preparation/order.vue
@@ -31,14 +31,95 @@
        :url="$api.insOrder.selectInsOrderParameter" :componentData="componentData"
        :upIndex="upIndex"  />
    </div>
    <el-dialog
      title="生成报告"
      :visible.sync="dialogVisible"
      width="60%"
      :append-to-body="true"
      :modal="!dialogVisible0"
      >
      <span>请选择委托编号为 {{currentInfo.entrustCode}} 要生成的数据</span>
      <el-card class="box-card" style="margin-top: 16px;" v-for="(item,index) in historyList" :key="index">
        <div slot="header" style="display: flex;justify-content: space-between;">
          <span>{{ item.laboratory }}</span>
          <!-- <el-checkbox v-model="item.checked"></el-checkbox> -->
        </div>
        <!-- <el-radio-group v-model="item.numValue" ref="radio">
          <el-radio :label="m.value" v-for="(m,i) in item.arr" :key="i"><el-link type="primary" @click="lookDetail(item,m.value)">{{ m.label }}</el-link></el-radio>
        </el-radio-group> -->
        <el-table
          :data="item.insOrderUserList"
          border
          style="width: 100%" @selection-change="list=>handleSelectionChange(list,item.insOrderUserList)">
          <el-table-column
            type="selection"
            width="55">
          </el-table-column>
          <el-table-column
            prop="submitTime"
            label="提交日期"
            width="150">
          </el-table-column>
          <el-table-column
            prop="submitUserName"
            label="提交人"
            width="90">
          </el-table-column>
          <el-table-column
            prop="term"
            label="实验阶段"
            width="120">
          </el-table-column>
          <el-table-column
            prop="note"
            label="实验操作"
            width="120">
          </el-table-column>
          <el-table-column
            prop="tell"
            label="再次检验原因"
            width="120">
          </el-table-column>
          <el-table-column
            fixed="right"
            label="操作"
            width="100">
            <template slot-scope="scope">
              <el-button @click="lookDetail(item,scope.row.num)" type="text" size="small">查看</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-card>
      <span slot="footer" class="dialog-footer">
        <el-button :loading="loading0" @click="handleNoCreate">不生成</el-button>
        <el-button type="primary" @click="handleCreate" :loading="loading1">生 成</el-button>
      </span>
    </el-dialog>
    <el-dialog
      title="检验详情"
      :visible.sync="dialogVisible0"
      width="100%" :fullscreen="true" :modal="false" :append-to-body="true">
      <Inspection v-if="dialogVisible0"
      :orderId="currentInfo.id"
      :inspectorList="currentItem.inspectorList"
      :sonLaboratory="currentItem.laboratory"
      :state="2"
      :orderStateId="currentItem.orderStateId"
      :version="currentItem.version"
      :isLook="true"
      :num1="currentItem.num1"
      :noBack="true"/>
    </el-dialog>
  </div>
</template>
<script>
import ValueTable from '../../tool/value-table.vue'
import Inspection from '../b1-inspect-order-plan/Inspection.vue'
export default {
  components: {
         ValueTable,
      Inspection,
      },
  data() {
    return {
@@ -124,7 +205,14 @@
        needSort: ['createTime', 'sendTime', 'type', 'appointed']
      },
      upIndex: 0,
      entityCopy: {}
      entityCopy: {},
      dialogVisible:false,
      historyList:[],
      currentInfo:{},
      currentItem:{},
      loading0:false,
      loading1:false,
      dialogVisible0:false
    }
  },
  mounted() {
@@ -154,42 +242,105 @@
      this.refreshTable()
    },
    handleCreateReport(row){
      this.$confirm(`是否生成此委托单 ${row.entrustCode} 的总报告?`, "提示", {
            confirmButtonText: "生成",
            cancelButtonText: "不生成",
            type: "success",
            distinguishCancelAndClose: true,
          }).then(() => {
            this.$axios.post(this.$api.insReport.isReport, {
              id:row.id,
              state:1
            }).then(res => {
              if (res.code === 201) {
                return
              }
              this.$message.success("已生成")
              this.refreshTable()
            }).catch(err => {
              console.log(err)
            })
          }).catch((e) => {
            console.log(e)
            if(e=='cancel'){
              this.$axios.post(this.$api.insReport.isReport, {
                id:row.id,
                state:0
              }).then(res => {
                if (res.code === 201) {
                  return
                }
                this.refreshTable()
                this.$message.success("已取消生成")
              }).catch(err => {
                console.log(err)
      this.currentInfo = row
      this.$axios.get(this.$api.insReport.getInsOrderStateCount+'?id='+row.id).then(res => {
        this.historyList = res.data
        this.historyList.forEach(item => {
          item.arr = []
          this.$set(item,'numValue',1)
          // item.checked = false;
          if(item.num>0){
            for(var i=0;i<item.num;i++){
              item.arr.push({
                label:'记录'+(i+1),
                value:i+1
              })
            }
          })
          }
        })
        this.dialogVisible = true
      })
    },
    // 生成报告
    handleCreate(){
      let arr = []
      this.historyList.forEach(item => {
        item.insOrderUserList.forEach(item1 => {
          if(item1.state==1){
            arr.push({
              laboratory:item.laboratory,
              num:item1.num
            })
          }
        })
      })
      if(arr.length==0){
        this.$message.error("请先选择需要生成的记录!")
        return
      }
      this.loading1 = true
      this.$axios.post(this.$api.insReport.isReport, {
        id:this.currentInfo.id,
        state:1,
        insReportDto1s:arr
      },{
        headers: {
          'Content-Type': 'application/json'
        }}).then(res => {
        this.loading1 = false
        if (res.code === 201) {
          return
        }
        this.$message.success("已生成")
        this.refreshTable()
        this.dialogVisible = false
      }).catch(err => {
        console.log(err)
      })
    },
    // 不生成
    handleNoCreate(){
      this.loading0 = true
      this.$axios.post(this.$api.insReport.isReport, {
            id:this.currentInfo.id,
            state:0
      },{
        headers: {
          'Content-Type': 'application/json'
        }}).then(res => {
          this.loading0 = false;
        if (res.code === 201) {
          return
        }
        this.refreshTable()
        this.$message.success("已取消生成")
        this.dialogVisible = false
      }).catch(err => {
        console.log(err)
      })
    },
    // 查看检验详情
    lookDetail(row,value){
      this.dialogVisible0 = true
      let inspectorList = []
      if(row.userName){
        inspectorList = row.userName.split(',')
      }
      this.currentItem = {
        num1:value,
        inspectorList:inspectorList,
        ...row
      }
    },
    handleSelectionChange(list,list0){
      list0.forEach(item => {
        let obj = list.find(item0 => item0.id == item.id)
        if(obj){
          item.state = 1
        }else{
          item.state = 0
        }
      })
    }
  }
}
@@ -227,4 +378,8 @@
      height: 100%;
      padding: 20px;
   }
  >>>.el-card__header,>>>.el-card__body{
    padding-top: 10px;
    padding-bottom: 10px;
  }
</style>