Newer
Older
xc-business-system / src / views / business / subpackage / certificate / dialog / selectSampleDialog.vue
<!-- 选择受检设备(如果有任务单就选择任务单下的样品、如果没有任务单就选择所有受检设备) -->
<script lang="ts" setup name="SelectOrderDetailEquipmentDialog">
import { ElMessage } from 'element-plus'
import { ref } from 'vue'
import type { TableColumn } from '@/components/NormalTable/table_interface'
import { getOrderDetail } from '@/api/business/manager/order'

const emits = defineEmits(['confirm'])
const dialogFormVisible = ref(false) // 控制对话框显隐
const isMulti = ref(false)// 表格是否多选
const orderId = ref('') // 任务单id、委托方id
const checkoutList = ref([]) // 多选选中的内容
const loadingTable = ref(false) // 表格loading
const list = ref([]) as any // 表格数据
const total = ref(0) // 数组总数
const columns = ref<TableColumn[]>([
  { text: '统一编号', value: 'sampleNo', align: 'center', width: '160' },
  { text: '设备名称', value: 'sampleName', align: 'center' },
  { text: '规格型号', value: 'sampleModel', align: 'center' },
  { text: '附件', value: 'appendixDescn', align: 'center' },
  { text: '外观和功能检查', value: 'appearanceInspect', align: 'center' },
  { text: '特殊要求', value: 'specialRequire', align: 'center' },
  { text: '检校项目', value: 'measureContent', align: 'center' },
])

// 数据查询
function fetchData() {
  loadingTable.value = true
  getOrderDetail({ id: orderId.value }).then((res) => {
    list.value = res.data.data.customerSampleInfoList
    loadingTable.value = false
  })
}

// 多选选中
const handleSelectionChange = (val: any) => {
  checkoutList.value = val
}

// 点击确定
const confirmSelect = () => {
  if (!checkoutList.value.length) {
    ElMessage.warning('请选择设备')
  }
  else {
    emits('confirm', checkoutList.value)
    dialogFormVisible.value = false
  }
}
// 取消
const resetForm = () => {
  dialogFormVisible.value = false
}
/**
 * 初始化
 * @param isMultiParam 是否多选 true多选、false单选
 * @param getOrderId 任务单id
 */
const initDialog = (isMultiParam: boolean, getOrderId: string) => {
  isMulti.value = isMultiParam
  orderId.value = getOrderId // 任务单id
  dialogFormVisible.value = true // 显示对话框
  if (orderId.value) {
    fetchData()
  }
}
// ----------------------------------------------钩子------------------------------------------------------
defineExpose({ initDialog })
</script>

<template>
  <el-dialog v-if="dialogFormVisible" v-model="dialogFormVisible" title="选择设备" width="65%">
    <!-- 查询结果Table显示 -->
    <div style="padding: 12px;">
      <normal-table
        :data="list"
        :total="total"
        :columns="columns"
        is-showmulti-select
        :list-loading="loadingTable"
        :is-multi="isMulti"
        :height="260"
        :pagination="false"
        @multi-select="handleSelectionChange"
      >
        <!-- 序号 -->
        <template #preColumns>
          <el-table-column label="#" width="55" align="center" fixed>
            <template #default="scope">
              {{ scope.$index + 1 }}
            </template>
          </el-table-column>
        </template>
      </normal-table>
    </div>
    <template #footer>
      <span class="dialog-footer">
        <el-button type="primary" @click="confirmSelect">确认</el-button>
        <el-button @click="resetForm">
          取消
        </el-button>
      </span>
    </template>
  </el-dialog>
</template>

<style lang="scss" scoped>
:deep(.el-radio__label) {
  display: none;
}
</style>