Newer
Older
xc-business-system / src / views / equipement / standard / book / dialog / selectCheckItem.vue
dutingting on 29 Nov 3 KB 解决冲突
<!-- 选择智能模型的哪个核查项去配置核查数据  -->
<script lang="ts" setup name="SelectCheckItemDialog">
import { ElMessage } from 'element-plus'
import type { Ref } from 'vue'
import { ref } from 'vue'
import type { TableColumn } from '@/components/NormalTable/table_interface'
import { getDictByCode } from '@/api/system/dict'
import type { dictType } from '@/global'

const props = defineProps({
  isMulti: { // 是否多选
    type: Boolean,
    default: false, // 默认单选
  },
})
// 用户信息
const emits = defineEmits(['confirm'])
const dialogFormVisible = ref(false)
const checkoutList = ref([]) // 多选选中的内容
const loadingTable = ref(false) // 表格loading
const list = ref([]) // 表格数据
const total = ref(0)
const type = ref('detail') // 跳转页面类型
const columns = ref<TableColumn[]>([
  { text: '标准库分类', value: 'equipmentTypeName', align: 'center', width: '120' },
  { text: '核查标准库', value: 'belongStandardEquipmentName', align: 'center' },
  { text: '核查项分类名称', value: 'categoryName', align: 'center' },
])
// -----------------------------------------字典--------------------------------------------------------------

const standardList = ref<dictType[]>([])// 检校标准库
const standardMap = ref({}) as any// 检校标准库

async function getDict() {
  // 检校标准库
  const res = await getDictByCode('bizStandardEquipmentType')
  res.data.forEach((item: { value: string; name: string }) => {
    standardMap.value[`${item.value}`] = item.name
  })
  standardList.value = res.data
}
// --------------------------------------------------------------------------------------------
// 多选选中
const handleSelectionChange = (val: any) => {
  checkoutList.value = val
}

// 点击确定
const confirmSelect = () => {
  if (!checkoutList.value.length) {
    ElMessage.warning('请选择智能模型核查项')
  }
  else {
    emits('confirm', checkoutList.value, type.value)
    dialogFormVisible.value = false
  }
}
// 取消
const resetForm = () => {
  dialogFormVisible.value = false
}
// 初始化
const initDialog = async (listParam: any, typeParam: string) => {
  getDict()
  type.value = typeParam // 跳转页面类型
  list.value = listParam
  dialogFormVisible.value = true
}

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="props.isMulti"
        :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>