Newer
Older
xc-business-system / src / views / resource / environment / require / dialog / selectLabRoomsDialog.vue
<!-- 选择选择环境系统的工作间 -->
<script lang="ts" setup name="SelectLabRoomsDialog">
import { ElMessage } from 'element-plus'
import type { Ref } from 'vue'
import { ref } from 'vue'
import dayjs from 'dayjs'
import type { DateModelType } from 'element-plus'
import { getLocationList } from '@/api/business/taskMeasure/measureData'
import { getStaffList } from '@/api/resource/register'
import type { TableColumn } from '@/components/NormalTable/table_interface'
import { SCHEDULE } from '@/utils/scheduleDict'
import { getCustomerInfoList } from '@/api/resource/customer'

const emits = defineEmits(['confirm'])
const dialogFormVisible = ref(false)
// 查询条件
const listQuery = ref({
  locationName: '', // 地点名称
  locationNo: '', // 地点编号
  labName: '', // 所属实验室
  limit: 20,
  offset: 1,
})
// 多选选中的内容
const checkoutList = ref([])
const loadingTable = ref(false)
const list = ref([]) // 表格数据
const total = ref(0)
const columns = ref<TableColumn[]>([
  { text: '地点名称', value: 'locationName', align: 'center', width: '160' },
  { text: '地点编号', value: 'locationNo', align: 'center' },
  { text: '地点位置', value: 'locationPosition', align: 'center' },
  { text: '所属实验室', value: 'locationLab', align: 'center' },
  { text: '创建人', value: 'createUser', align: 'center' },
  { text: '创建时间', value: 'createTime', align: 'center', width: '180' },
])
const dateRange = ref<[DateModelType, DateModelType]>(['', ''])// 筛选时间段数据

const handleSelectionChange = (val: any) => {
  checkoutList.value = val
}
// 数据查询
function fetchData(isNowPage = false) {
  loadingTable.value = true
  if (!isNowPage) {
    // 是否显示当前页,否则跳转第一页
    listQuery.value.offset = 1
  }
  getLocationList(listQuery.value).then((response) => {
    list.value = response.data.rows
    total.value = parseInt(response.data.total)
    loadingTable.value = false
  })
}
// 重置
const clearList = () => {
  listQuery.value = {
    locationName: '', // 地点名称
    locationNo: '', // 地点编号
    labName: '', // 所属实验室
    limit: 20,
    offset: 1,
  }
  dateRange.value = ['', '']
  fetchData()
}
// 搜索
const search = () => {
  fetchData(true)
}

// 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写
const changePage = (val: { size?: number;page?: number }) => {
  if (val && val.size) {
    listQuery.value.limit = val.size
  }
  if (val && val.page) {
    listQuery.value.offset = val.page
  }
  search()
}
// 点击确定
const confirmSelect = (row: any) => {
  emits('confirm', [row])
  dialogFormVisible.value = false
}
// 取消
const resetForm = () => {
  dialogFormVisible.value = false
  clearList()
}
// 初始化
const initDialog = () => {
  dialogFormVisible.value = true
  fetchData()
}

defineExpose({ initDialog })
</script>

<template>
  <el-dialog v-if="dialogFormVisible" v-model="dialogFormVisible" title="选择工作间" width="65%">
    <!-- 筛选条件 -->
    <search-area :need-clear="true" @search="search" @clear="clearList">
      <search-item>
        <el-input v-model.trim="listQuery.locationNo" placeholder="地点编号" class="short-input" clearable />
      </search-item>
      <search-item>
        <el-input v-model.trim="listQuery.locationName" placeholder="地点名称" class="short-input" clearable />
      </search-item>
    </search-area>

    <!-- 查询结果Table显示 -->
    <div style="padding: 12px;">
      <normal-table
        :data="list"
        :total="total"
        :columns="columns"
        :query="listQuery"
        is-showmulti-select
        :list-loading="loadingTable"
        :is-multi="false"
        :height="520"
        @change="changePage"
        @multi-select="handleSelectionChange"
        :isShowSingleSelectButton="true"
      >
        <!-- 序号 -->
        <template #preColumns>
          <el-table-column label="#" width="55" align="center" fixed>
            <template #default="scope">
              {{ (listQuery.offset - 1) * listQuery.limit + scope.$index + 1 }}
            </template>
          </el-table-column>
        </template>
        <template #columns>
          <el-table-column fixed="right" label="操作" align="center" width="130">
            <template #default="{ row }">
              <el-button size="small" type="primary" @click="confirmSelect(row)">
                选定
              </el-button>
            </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>