Newer
Older
xc-business-system / src / views / quality / review / run / components / templateDialog.vue
lyg on 22 Dec 2023 4 KB 质量模块按钮权限
<!-- 用户列表弹窗 -->
<script lang="ts" setup name="TemplateDialog">
import { ElMessage } from 'element-plus'
import type { TableColumn } from '@/components/NormalTable/table_interface'
import { getTemplateItemsList } from '@/api/quality/template/template'
import quality from '/public/config/quality.json'
const emits = defineEmits(['add'])
const dialogFormVisible = ref(false)
const { proxy } = getCurrentInstance() as any
const listQuery = ref({
  itemTitle: '',
  inspectionContent: '',
  inspectionMethod: '',
  inspectionRes: '',
  refStandard: '',
  temTips: `${quality.nbjlgl},${quality.nbjszy}`,
  limit: 5,
  offset: 1,
})

const columns = ref<TableColumn[]>([
  { text: '内容标题', value: 'itemTitle', align: 'center' },
  { text: '质量管理体系运行情况', value: 'inspectionContent', align: 'center' },
  { text: '存在问题', value: 'inspectionMethod', align: 'center' },
  { text: '对策', value: 'inspectionRes', align: 'center' },
  // { text: '依据(GJB2725A 质量手册、程序文件)', value: 'refStandard', align: 'center' },
])
const tableList = ref([])
const loadingTable = ref(true)
const total = ref(0)
const searchList = () => {
  loadingTable.value = true
  getTemplateItemsList(listQuery.value).then((res) => {
    tableList.value = res.data.rows
    total.value = Number(res.data.total)
    loadingTable.value = false
  })
}
searchList()
// 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写
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
  }
  searchList()
}
const clearList = () => {
  listQuery.value = {
    itemTitle: '',
    inspectionContent: '',
    inspectionMethod: '',
    inspectionRes: '',
    refStandard: '',
    temTips: `${proxy.config.nbjlgl},${proxy.config.nbjszy}`,
    limit: 5,
    offset: 1,
  }
  searchList()
}
// 单选选中
const checkoutList = ref<any[]>([])
const checkSelect = (val: any) => {
  checkoutList.value = val
}
// 点击保存
const submitForm = () => {
  if (checkoutList.value.length) {
    emits('add', checkoutList.value[0])
    dialogFormVisible.value = false
  }
  else {
    ElMessage.warning('请先选择模板')
  }
}
// 取消
const resetForm = () => {
  dialogFormVisible.value = false
}
// 初始化
const initDialog = () => {
  dialogFormVisible.value = true
}
defineExpose({ initDialog })
</script>

<template>
  <el-dialog v-model="dialogFormVisible" title="选择模板" width="65%">
    <!-- 筛选条件 -->
    <search-area :need-clear="true" @search="searchList" @clear="clearList">
      <search-item>
        <el-input v-model="listQuery.itemTitle" placeholder="内容标题" />
      </search-item>
      <search-item>
        <el-input v-model="listQuery.inspectionContent" placeholder="运行情况" />
      </search-item>
      <search-item>
        <el-input v-model="listQuery.inspectionMethod" placeholder="存在问题" />
      </search-item>
      <search-item>
        <el-input v-model="listQuery.refStandard" placeholder="对策" />
      </search-item>
    </search-area>
    <table-container>
      <!-- <template #btns-right>
        <icon-button icon="icon-add" title="新建" type="primary" />
        <icon-button icon="icon-export" title="导出" type="primary" />
      </template> -->
      <normal-table
        :data="tableList" :total="total" :query="listQuery" :columns="columns" :list-loading="loadingTable"
        :is-showmulti-select="false" :is-multi="false" @change="changePage" @multi-select="checkSelect"
      >
        <template #preColumns>
          <el-table-column label="序号" width="55" align="center">
            <template #default="scope">
              {{ scope.$index + 1 }}
            </template>
          </el-table-column>
        </template>
      </normal-table>
    </table-container>
    <template #footer>
      <span class="dialog-footer">
        <el-button type="primary" @click="submitForm">确认</el-button>
        <el-button @click="resetForm">
          取消
        </el-button>
      </span>
    </template>
  </el-dialog>
</template>

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