<!-- 标准装置台账信息列表 --> <script name="StandardBookInfoList" lang="ts" setup> import type { Ref } from 'vue' import { getCurrentInstance, onMounted, ref, watch } from 'vue' import type { DateModelType } from 'element-plus' import { ElLoading, ElMessage, ElMessageBox } from 'element-plus' import dayjs from 'dayjs' import type { IList, IListQuery } from './book-interface' import buttonBox from '@/components/buttonBox/buttonBox.vue' import type { deptType, dictType } from '@/global' import { exportFile } from '@/utils/exportUtils' import type { TableColumn } from '@/components/NormalTable/table_interface' import { SCHEDULE } from '@/utils/scheduleDict' import { getDictByCode } from '@/api/system/dict' import type { IMenu } from '@/components/buttonBox/buttonBox' const $router = useRouter() const { proxy } = getCurrentInstance() as any const active = ref('') const buttonBoxActive = 'StandardBookInfo' // 存储在sessionstorage里面的字段名,用于记录右上角buttonbox点击状态 const operateWidth = ref('150') // 操作栏的宽度 // 查询条件 const listQuery: Ref<IListQuery> = ref({ name: '', // 标准装置名称 position: '', // 存放地点 techFile: '', // 依据的技术文件 offset: 1, limit: 20, }) const total = ref(0) // 数据条数 const loadingTable = ref(false) // 表格loading const menu = ref<IMenu[]>([]) // 审批状态按钮组合 // 表头 const columns = ref<TableColumn[]>([ { text: '标准代码', value: 'standardNo', align: 'center' }, { text: '计量标准装置名称', value: 'name', align: 'center' }, { text: '测量范围', value: 'range', align: 'center' }, { text: '不确定度或允许误差极限或准确度等级', value: 'level', align: 'center' }, { text: '建标日期', value: 'date', align: 'center', width: '120' }, { text: '最近复查日期', value: 'fcDate', align: 'center', width: '120' }, { text: '计量标准证书号', value: 'number', align: 'center' }, { text: '检定或校准项目', value: 'content', align: 'center' }, ]) const list = ref<IList[]>([]) // 表格数据 const checkoutList = ref<string[]>([])// 选中的内容 // -----------------------------------------字典-------------------------------------------------------------- const techFilesList = ref<deptType[]>([]) // 依据的技术文件 // 查询字典 const getDict = async () => { // 审批状态 const res = await getDictByCode('approvalStatus') // 制作右上角的菜单 res.data.forEach((item: dictType) => { if (item.name === '全部' || item.name === '已审批' || item.name === '待审批' || item.name === '审批' || item.name === '草稿箱' || item.name === '审批中' || item.name === '已通过' || item.name === '未通过' || item.name === '已取消') { menu.value.push({ name: item.name, id: `${item.value}`, }) } }) // 获取技术文件 // getUserList({ offset: 1, limit: 999999 }).then((res: any) => { // userList.value = res.data.rows // }) } // ------------------------------------------------------------------------------------------------------- // 数据查询 function fetchData(isNowPage = false) { loadingTable.value = true if (!isNowPage) { // 是否显示当前页,否则跳转第一页 listQuery.value.offset = 1 } // getContractList(listQuery.value).then((response) => { // list.value = response.data.rows.map((item: { estimateSignDate: string; agreementAmount: number }) => { // return { // ...item, // estimateSignDate: item.estimateSignDate ? dayjs(item.estimateSignDate).format('YYYY-MM-DD') : item.estimateSignDate, // agreementAmount: calc(Number(item.agreementAmount), 100, '/'), // } // }) // total.value = parseInt(response.data.total) // loadingTable.value = false // }).catch(() => { loadingTable.value = false // }) list.value = [ { id: 'test', // 主键 standardNo: 'test', // 标准代码 name: 'test', // 计量标准装置名称 range: 'test', // 测量范围 level: 'test', // 不确定度或允许误差极限或准确度等级 date: 'test', // 建标日期 fcDate: 'test', // 最近复查日期 number: 'test', // 计量标准证书号 content: 'test', // 检定或校准项目 }, ] } // 搜索 const searchList = () => { fetchData(true) } // 重置 const clearList = () => { listQuery.value = { name: '', // 标准装置名称 position: '', // 存放地点 techFile: '', // 依据的技术文件 offset: 1, limit: 20, } fetchData(true) } // 多选发生改变时 function handleSelectionChange(e: any) { checkoutList.value = e.map((item: { id: string }) => item.id) } // 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写 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 } fetchData(true) } // 导出word const exportWord = () => {} // 导出pdf const exportPdf = () => {} // 新建 const add = () => { $router.push({ path: '/standard/add' }) } // ----------------------------------------------操作--------------------------------------------------- const handleEdit = (row: IList, type: string) => { // 查看编辑 if (type === 'detail' || type === 'edit') { $router.push({ path: `/standard/${type}/${row.id}`, query: { // id: row.id, }, }) } else if (type === 'delete') { // 删除 ElMessageBox.confirm( '确认删除吗?', '提示', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning', }, ) .then(() => { // 调删除接口,成功后刷新列表 }) } } // ------------------------------------审批--------------------------------------------------------------------- // 切换tab状态 const changeCurrentButton = (val: string) => { active.value = val // 此时的tab window.sessionStorage.setItem(buttonBoxActive, val) // 记录tab状态 clearList() // 刷新 } // 审批结束回调 const approvalSuccess = () => { fetchData(true) } // ----------------------------------------------钩子------------------------------------------------------ onMounted(async () => { await getDict() if (window.sessionStorage.getItem(buttonBoxActive)) { active.value = window.sessionStorage.getItem(buttonBoxActive)! } else { active.value = menu.value.find(item => item.name === '全部')!.id as string // 全部 } fetchData(true) }) </script> <template> <app-container> <search-area :need-clear="true" @search="searchList" @clear="clearList"> <search-item> <el-input v-model.trim="listQuery.name" placeholder="标准装置名称" class="short-input" clearable /> </search-item> <search-item> <el-input v-model.trim="listQuery.position" placeholder="存放地点" class="short-input" clearable /> </search-item> <search-item> <el-input v-model.trim="listQuery.techFile" placeholder="依据的技术文件" class="short-input" clearable /> </search-item> </search-area> <table-container> <template #btns-right> <icon-button icon="icon-word" title="导出word" type="primary" @click="exportWord" /> <icon-button icon="icon-pdf" title="导出pdf" type="primary" @click="exportPdf" /> <icon-button icon="icon-add" title="新建" type="primary" @click="add" /> </template> <normal-table :data="list" :total="total" :columns="columns" :query="listQuery" :list-loading="loadingTable" is-showmulti-select @change="changePage" @multi-select="handleSelectionChange" > <template #preColumns> <el-table-column label="序号" width="55" align="center"> <template #default="scope"> {{ (listQuery.offset - 1) * listQuery.limit + scope.$index + 1 }} </template> </el-table-column> </template> <template #columns> <el-table-column label="操作" align="center" fixed="right" :width="operateWidth" > <template #default="{ row }"> <el-button size="small" type="primary" link @click="handleEdit(row, 'detail')" > 详情 </el-button> <el-button size="small" type="primary" link @click="handleEdit(row, 'edit')" > 编辑 </el-button> <el-button size="small" type="danger" link @click="handleEdit(row, 'delete')" > 删除 </el-button> </template> </el-table-column> </template> </normal-table> </table-container> <!-- 审批弹窗 --> <approval-dialog ref="approvalDialog" @on-success="approvalSuccess" /> <!-- 右上角按钮集合 --> <button-box :active="active" :menu="menu" @change-current-button="changeCurrentButton" /> </app-container> </template> <style lang="ts" scoped> </style>