Newer
Older
xc-business-system / src / views / business / taskMeasure / myTask / dialog / selectItemDialog.vue
dutingting on 16 Nov 2023 3 KB 检定数据管理联调
<!-- 选择设备的哪个检定项去配置检定数据  -->
<script lang="ts" setup name="SelectItemDialog">
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'
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 columns = ref<TableColumn[]>([
  { text: '设备名称', value: 'deviceName', align: 'center' },
  { text: '型号规格', value: 'model', align: 'center' },
  { text: '辅助字段', value: 'helpInstruction', align: 'center' },
  { text: '辅助字段说明', value: 'helpInstruction', align: 'center' },
  { text: '设备分类', value: 'deviceTypeName', align: 'center' },
  { text: '检校标准装置', value: 'belongStandardEquipmentName', align: 'center' },
  { text: '设备检定项分类', value: 'itemCategoryName', align: 'center' },
  { text: '检定项更新时间', value: 'updateTime', align: 'center', width: '180' },
  { text: '自动检定系统数据是否同步', value: 'dataSyncStr', align: 'center' },
  { text: '自动检定系统最新同步时间', value: 'updateTime', align: 'center', width: '180' },
])
// -----------------------------------------字典--------------------------------------------------------------
const isSyncMap = ref({}) as any // 是否同步{1: 是}
const isSyncList = ref({}) as any // 是否同步
// 查询字典
const getDict = async () => {
  // 是否同步
  getDictByCode('bizBusinessMeasureIsSync').then((response) => {
    isSyncList.value = response.data
    response.data.forEach((item: any) => {
      isSyncMap.value[`${item.value}`] = item.name
    })
  })
}
// --------------------------------------------------------------------------------------------
// 多选选中
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
}
// 初始化
const initDialog = async (listParam: any) => {
  getDict()
  list.value = listParam
  console.log(list.value)

  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>