123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- <template>
- <a-card :bordered="false" v-if="indexShow">
- <s-table
- ref="tableRef"
- :columns="columns"
- :data="loadData"
- :alert="options.alert.show"
- bordered
- :row-key="(record) => record.id"
- :tool-config="toolConfig"
- :row-selection="options.rowSelection"
- v-model:filterParam="filterParam"
- :scroll="{ x: 2000 }"
- >
- <template #operator class="table-operator">
- <a-space>
- <a-button type="primary" @click="onDetail()" v-if="hasPerm('qyRecordAttachmentAdd')">
- <template #icon><plus-outlined /></template>
- 新增
- </a-button>
- <xn-batch-delete
- v-if="hasPerm('qyRecordAttachmentDelete')"
- :selectedRowKeys="selectedRowKeys"
- @batchDelete="deleteBatchQyRecordAttachment"
- />
- <a-button @click="onExport" v-if="hasPerm('qyRecordAttachmentBatchExport')">
- <template #icon><export-outlined /></template>
- 批量导出
- </a-button>
- </a-space>
- </template>
- <template #bodyCell="{ column, record }">
- <template v-if="column.dataIndex === 'action'">
- <a-space>
- <a @click="onDetail(record, true)" v-if="hasPerm('qyRecordAttachmentView')">查看</a>
- <a-divider type="vertical" v-if="hasPerm('qyRecordAttachmentView') && hasPerm(['qyRecordAttachmentEdit', 'qyRecordAttachmentDelete'], 'or')" />
- <a @click="onDetail(record)" v-if="hasPerm('qyRecordAttachmentEdit')">编辑</a>
- <a-divider type="vertical" v-if="hasPerm(['qyRecordAttachmentEdit', 'qyRecordAttachmentDelete'], 'and')" />
- <a-popconfirm title="确定要删除吗?" @confirm="deleteQyRecordAttachment(record)">
- <a-button type="link" danger size="small" v-if="hasPerm('qyRecordAttachmentDelete')">删除</a-button>
- </a-popconfirm>
- </a-space>
- </template>
- </template>
- </s-table>
- </a-card>
- <Detail v-else ref="detailRef" @onClose="indexShow = true" @successful="onSearch()" />
- </template>
- <script setup name="qyrecordattachment">
- import { cloneDeep } from 'lodash-es'
- import Detail from './detail.vue'
- import qyRecordAttachmentApi from '@/api/yqyc/qyRecordAttachmentApi'
- import downloadUtil from "@/utils/downloadUtil";
- const { proxy } = getCurrentInstance()
- const tableRef = ref()
- const filterParam = ref({})
- const detailRef = ref()
- const indexShow = ref(true)
- const toolConfig = { refresh: true, height: true, columnSetting: true, striped: false }
- const columns = [
- {
- title: '附件名称',
- dataIndex: 'attachmentName',
- },
- {
- title: '附件格式',
- dataIndex: 'attachmentFormat',
- },
- {
- title: '附件内容',
- dataIndex: 'attachmentContent',
- },
- {
- title: '上传时间',
- dataIndex: 'uploadTime',
- },
- ]
- // 操作栏通过权限判断是否显示
- if (hasPerm(['qyRecordAttachmentEdit', 'qyRecordAttachmentDelete'])) {
- columns.push({
- title: '操作',
- dataIndex: 'action',
- align: 'center',
- width: 200,
- fixed: 'right',
- })
- }
- const selectedRowKeys = ref([])
- // 列表选择配置
- const options = {
- // columns数字类型字段加入 needTotal: true 可以勾选自动算账
- alert: {
- show: true,
- clear: () => {
- selectedRowKeys.value = ref([])
- }
- },
- rowSelection: {
- onChange: (selectedRowKey, selectedRows) => {
- selectedRowKeys.value = selectedRowKey
- }
- }
- }
- const loadData = (parameter) => {
- tableRef.value.clearSelected()
- return qyRecordAttachmentApi.qyRecordAttachmentPage(parameter).then((data) => {
- return data
- })
- }
- // 搜索同时备份参数
- const onSearch = (parameter) => {
- searchFormStateReal.value = cloneDeep(Object.assign(searchFormState.value, filterParam.value))
- nextTick(() => {
- tableRef.value.refresh(parameter)
- })
- }
- // 重置
- const reset = () => {
- searchFormRef.value.resetFields()
- onSearch(true)
- }
- // 删除
- const deleteQyRecordAttachment = (record) => {
- let params = [
- {
- id: record.id
- }
- ]
- qyRecordAttachmentApi.qyRecordAttachmentDelete(params).then(() => {
- tableRef.value.refresh(true)
- })
- }
- // 批量删除
- const deleteBatchQyRecordAttachment = (params) => {
- qyRecordAttachmentApi.qyRecordAttachmentDelete(params).then(() => {
- tableRef.value.clearRefreshSelected()
- })
- }
- // 批量导出
- const onExport = () => {
- const params = {
- ...filterParam.value
- }
- if (selectedRowKeys.value.length > 0) {
- params.ids = selectedRowKeys.value
- } else {
- Object.entries(searchFormStateReal.value).forEach(([key, value]) => {
- console.log(key)
- if (proxy.$util.isValue(value)) {
- params[key] = value
- }
- })
- }
- qyRecordAttachmentApi.qyRecordAttachmentExport(params).then((res) => {
- downloadUtil.resultDownload(res)
- tableRef.value.clearSelected()
- })
- }
- // 切换至表单
- const onDetail = (record = null, view) => {
- indexShow.value = false
- nextTick(() => {
- detailRef.value.onOpen(record, view)
- })
- }
- </script>
- <style lang="less" scoped>
- </style>
|