hldy_yunwei_vue/src/views/iot/weihu/index.vue

157 lines
4.3 KiB
Vue

<template>
<div>
<!--引用表格-->
<BasicTable @register="registerTable" :rowSelection="rowSelection" @selection-change="handleSelectionChange" size="small">
<!--插槽:table标题-->
<template #tableTitle>
<a-button v-if="selectedRowKeys.length > 0" preIcon="ant-design:flag-outlined" @click="handleSendOrg" >选择发往机构</a-button>
</template>
<template #form-depart="{model,field}">
<a-select ref="select"
placeholder="请选择机构"
v-model:value="model[field]"
@change="handleChange">
<a-select-option :value="item.orgCode" v-for="item in departInfos" :key="item.orgCode">{{item.departName}}</a-select-option>
</a-select>
</template>
<template #form-nuArea="{model,field}">
<a-select ref="select"
placeholder="请选择区域"
v-model:value="model[field]">
<a-select-option :value="item.nuId" v-for="item in nuInfos" :key="item.nuId">{{item.nuId}}</a-select-option>
</a-select>
</template>
<!--操作栏-->
<template #action="{ record }">
<TableAction :actions="getTableAction(record)"/>
</template>
</BasicTable>
<SendOrgDrawer @register="registerDrawer" @success="handleSuccess" />
<ReamrksListModal ref="remarksModal"></ReamrksListModal>
</div>
</template>
<script lang="ts" name="iot-weihu" setup>
import {onMounted, reactive, ref} from 'vue';
import { BasicTable, TableAction } from '/@/components/Table';
import { useListPage } from '/@/hooks/system/useListPage';
import { list,departlist,nulist } from './weihu.api';
import { columns, searchFormSchema } from './weihu.data';
import { useDrawer } from "@/components/Drawer";
import SendOrgDrawer from './components/SendOrgDrawer.vue';
import ReamrksListModal from './components/ReamrksListModal.vue'
const [registerDrawer, { openDrawer }] = useDrawer();
const queryParam = reactive<any>({});
const selectedRows = ref<any[]>([]);
const remarksModal = ref();
//注册table数据
const { prefixCls,tableContext } = useListPage({
tableProps:{
title: '设备维修',
api: list,
columns,
canResize:false,
showIndexColumn: true,
formConfig: {
labelWidth: 120,
schemas: searchFormSchema,
showAdvancedButton: false
},
actionColumn: {
width: 120,
fixed:'right'
},
beforeFetch: (params) => {
return Object.assign(params, queryParam);
},
},
})
const [registerTable, {reload},{ rowSelection, selectedRowKeys }] = tableContext
function handleSelectionChange(selectedRowSet) {
selectedRows.value = selectedRowSet.rows;
console.log('当前选中数据:', selectedRows.value);
}
function handleSendOrg(){
openDrawer(true, {
records : selectedRows.value,
isUpdate: true,
showFooter: true,
tenantSaas: false,
});
}
/**
* 成功回调
*/
function handleSuccess() {
(selectedRowKeys.value = []) && reload();
}
// function handleDetail(record){
// let records = [];
// records.push(record);
// openDrawer(true, {
// records : records,
// isUpdate: true,
// showFooter: false,
// tenantSaas: false,
// });
// }
function handleDetail(record){
remarksModal.value.disableSubmit = true;
remarksModal.value.edit(record)
}
/**
* 操作栏
*/
function getTableAction(record){
return [
// {
// label: '备注',
// onClick: handleDetail.bind(null, record),
// },
{
label: '备注',
onClick: handleDetail.bind(null, record),
},
];
}
const departInfos = ref();
async function getDepartInfos(){
departInfos.value = await departlist({});
}
const nuInfos = ref();
async function getNuInfos(){
nuInfos.value = await nulist({});
}
async function handleChange(record){
var params = {orgCode:record};
nuInfos.value = await nulist(params);
}
onMounted(() => {
getDepartInfos();
getNuInfos();
});
</script>
<style lang="less" scoped>
:deep(.selected-row) {
background-color: #e6f7ff !important;
&:hover td {
background-color: #e6f7ff !important;
}
}
</style>