import { reactive } from 'vue' import { optTextMap, statusMap } from '@/utils/map' import { facilitiesSuggestRateConfigDel, facilitiesSuggestRateConfigCopy, facilitiesSuggestRateConfigEnable } from '@/api/preassess/scaleConfig' export default function useColumns(proxy, getTableList) { const visible = ref(false) const row = ref({}) const opts = reactive({ type: '', text: '' }) const columns = reactive([ { prop: 'configName', label: '记录名称', render: ({ row }) => { return <span style="color: #409eef">{ row.configName }</span> }, width: 200, 'show-overflow-tooltip': true }, { prop: 'startDatetime', label: '启用时间', align: 'center' }, { prop: 'endDatetime', label: '停用时间', align: 'center' }, { prop: 'updateBy', label: '修改人', align: 'center' }, { prop: 'updateTime', label: '修改日期', align: 'center' }, { prop: 'status', label: '使用状态', align: 'center', render: ({ row }) => { return ( row.status ? <Fragment> <el-tag type={statusMap.get(row.status).type}>{ statusMap.get(row.status).text }</el-tag> </Fragment> : null ) } }, { label: '操作', render: ({ row }) => { return ( <Fragment> <el-button type="primary" link onClick={ () => copy(row) }>复制</el-button> <el-button type="primary" link disabled={ row.status === '1' } onClick={ () => enable(row) }>启用</el-button> <el-button type="primary" link onClick={ () => openDialog(row, 'view') }>查看</el-button> <el-button type="primary" link onClick={ () => openDialog(row, 'edit') }>修改</el-button> <el-button type="danger" link onClick={ () => del(row) }>删除</el-button> </Fragment> ) }, align: 'center', width: 254 } ]) const openDialog = (data, type) => { visible.value = true opts.type = type opts.text = optTextMap.get(type) row.value = data } const del = (row) => { proxy.$modal .confirm("是否确认删除?") .then(async () => { const res = await facilitiesSuggestRateConfigDel(row.id) if(res?.code !== 200) return proxy.$modal.msgSuccess('操作成功!') getTableList() }) .catch(() => {}) } const copy = (row) => { proxy.$modal .confirm("是否确认复制?") .then(async () => { const res = await facilitiesSuggestRateConfigCopy({ id: row.id }) if(res?.code !== 200) return proxy.$modal.msgSuccess('操作成功!') getTableList() }) .catch(() => {}) } const enable = (row) => { proxy.$modal .confirm("是否确认启用?") .then(async () => { const res = await facilitiesSuggestRateConfigEnable(row.id) if(res?.code !== 200) return proxy.$modal.msgSuccess('操作成功!') getTableList() }) .catch(() => {}) } return { columns, visible, row, opts, openDialog, } }