feat:交接班类型管理
This commit is contained in:
1 parent
be9b2f1f11
commit
a2314e25b3
7 files changed
+425
-15
No files matched your search
@@ -0,0 +1,49 @@
|
||||
import request from "/@/utils/request"
|
||||
|
||||
export function select(query?: Object) {
|
||||
return request({
|
||||
url: '/admin/sysDutyType/select',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchList(query?: Object) {
|
||||
return request({
|
||||
url: '/admin/sysDutyType/page',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function addObj(obj?: Object) {
|
||||
return request({
|
||||
url: '/admin/sysDutyType',
|
||||
method: 'post',
|
||||
data: obj
|
||||
})
|
||||
}
|
||||
|
||||
export function getObj(id?: string) {
|
||||
return request({
|
||||
url: '/admin/sysDutyType/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function delObjs(ids?: Object) {
|
||||
return request({
|
||||
url: '/admin/sysDutyType',
|
||||
method: 'delete',
|
||||
data: ids
|
||||
})
|
||||
}
|
||||
|
||||
export function putObj(obj?: Object) {
|
||||
return request({
|
||||
url: '/admin/sysDutyType',
|
||||
method: 'put',
|
||||
data: obj
|
||||
})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
<template>
|
||||
<el-select style="width: 100%" v-model="state.selectId" :placeholder="props.placeholder"
|
||||
:clearable="props.clearable" remote-show-suffix filterable remote :disabled="props.disabled"
|
||||
:remote-method="remoteSearch" :loading="state.loading" @visible-change="(e: boolean) => e && getOptions()"
|
||||
@change="change">
|
||||
<el-option v-for="v in state.options" :key="v.id" :label="`${v.name}`" :value="v.id">
|
||||
<div class="flex items-center">
|
||||
<div class="flex items-center justify-center mr5">
|
||||
<dict-tag :options="state.type" :value="v.bizType" />
|
||||
</div>
|
||||
<div class="color-primary">{{ v.name }}</div>
|
||||
</div>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="select-duty-type">
|
||||
import { reactive } from "vue"
|
||||
import { useDict } from "/@/hooks/dict"
|
||||
|
||||
import * as AreaManageApi from "/@/api/sys/sysDutyType"
|
||||
|
||||
const emit = defineEmits(["change"])
|
||||
|
||||
const selectId = defineModel()
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
placeholder?: string
|
||||
disabled?: boolean
|
||||
clearable?: boolean
|
||||
autoFirst?: boolean
|
||||
apiParams?: any
|
||||
}>(),
|
||||
{
|
||||
placeholder: "请选择",
|
||||
disabled: false,
|
||||
clearable: true,
|
||||
autoFirst: false,
|
||||
apiParams: {},
|
||||
},
|
||||
)
|
||||
|
||||
const queryForm = reactive<any>({
|
||||
name: "",
|
||||
current: 1,
|
||||
size: 10,
|
||||
})
|
||||
|
||||
const state = reactive<any>({
|
||||
loading: true,
|
||||
selectId: selectId,
|
||||
options: [],
|
||||
type: [],
|
||||
})
|
||||
|
||||
watch(
|
||||
selectId,
|
||||
(newVal, oldValue) => {
|
||||
if (newVal == oldValue) return
|
||||
state.selectId = newVal
|
||||
getOptions()
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
async function getOptions() {
|
||||
try {
|
||||
state.loading = true
|
||||
const _pa = {
|
||||
...queryForm,
|
||||
...props.apiParams,
|
||||
}
|
||||
const { data } = await AreaManageApi.select(_pa)
|
||||
state.options = data.records ?? []
|
||||
if (props.autoFirst && state.options.length != 0) {
|
||||
state.selectId = state.options[0].id
|
||||
emit("change", state.selectId)
|
||||
}
|
||||
const { sys_duty_type } = useDict("sys_duty_type")
|
||||
state.type = sys_duty_type
|
||||
} finally {
|
||||
setTimeout(() => (state.loading = false), 500)
|
||||
}
|
||||
}
|
||||
|
||||
function remoteSearch(params: string) {
|
||||
if (params != queryForm.name) {
|
||||
queryForm.name = params
|
||||
getOptions()
|
||||
}
|
||||
}
|
||||
|
||||
function clear() {
|
||||
state.selectId = null
|
||||
getOptions()
|
||||
}
|
||||
|
||||
function change() {
|
||||
emit("change", selectId)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
props.autoFirst && getOptions()
|
||||
})
|
||||
</script>
|
||||
@@ -24,6 +24,7 @@ import TagUserStatus from "/@/components/Tag/TagUserStatus.vue"
|
||||
|
||||
import SelectArea from "/@/components/Select/SelectArea.vue"
|
||||
import SelectDevice from "/@/components/Select/SelectDevice.vue"
|
||||
import SelectDutyType from "/@/components/Select/SelectDutyType.vue"
|
||||
|
||||
import ColumnBtn from "/@/components/Column/ColumnBtn.vue"
|
||||
|
||||
@@ -78,7 +79,7 @@ export default {
|
||||
|
||||
app.component('SelectArea', SelectArea);
|
||||
app.component('SelectDevice', SelectDevice);
|
||||
// app.component('DictSelect', DictSelect);
|
||||
app.component('SelectDutyType', SelectDutyType);
|
||||
|
||||
app.component('ColumnBtn', ColumnBtn);
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
</el-col>
|
||||
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="值班时间段" prop="timeType">
|
||||
<dict-select v-model="form.timeType" :options="duty_time_type" placeholder="请选择值班时间段" />
|
||||
<el-form-item label="值班时间段" prop="timeTypeId">
|
||||
<select-duty-type v-model="form.timeTypeId" :apiParams="{ bizType: '1' }" placeholder="请选择值班时间段" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
@@ -81,7 +81,7 @@ const { duty_time_type } = useDict("duty_time_type")
|
||||
const form = reactive({
|
||||
id: '',
|
||||
dutyTime: parseDate(new Date(), '{y}-{m}-{d}'),
|
||||
timeType: '3',
|
||||
timeTypeId: '',
|
||||
personId: '',
|
||||
personName: '',
|
||||
areaId: '',
|
||||
@@ -95,7 +95,7 @@ const dataRules = ref({
|
||||
dutyTime: [
|
||||
{ required: true, message: '值班时间不能为空', trigger: 'blur' }
|
||||
],
|
||||
timeType: [
|
||||
timeTypeId: [
|
||||
{ required: true, message: '值班时间段不能为空', trigger: 'change' }
|
||||
],
|
||||
personName: [
|
||||
|
||||
@@ -10,8 +10,9 @@
|
||||
<el-form-item style="width: 250px;" label="值班位置" prop="areaName">
|
||||
<el-input v-model="state.queryForm.areaName" placeholder="请输入值班位置" />
|
||||
</el-form-item>
|
||||
<el-form-item style="width: 250px;" label="值班时间段" prop="timeType">
|
||||
<dict-select v-model="state.queryForm.timeType" :options="duty_time_type" placeholder="请选择值班时间段" />
|
||||
<el-form-item style="width: 250px;" label="值班时间段" prop="timeTypeId">
|
||||
<select-duty-type v-model="state.queryForm.timeTypeId" :apiParams="{ bizType: '1' }"
|
||||
placeholder="请选择值班时间段" />
|
||||
</el-form-item>
|
||||
<el-form-item style="width: 450px;" label="值班时间" prop="dutyTimeList">
|
||||
<el-date-picker v-model="state.queryForm.dutyTimeList" value-format="YYYY-MM-DD" type="daterange" />
|
||||
@@ -44,9 +45,9 @@
|
||||
<el-table-column type="selection" width="40" align="center" />
|
||||
<el-table-column type="index" label="#" width="40" />
|
||||
<el-table-column prop="dutyTime" label="值班时间" />
|
||||
<el-table-column prop="timeType" label="值班时间段">
|
||||
<el-table-column prop="parseTimeType" label="值班时间段">
|
||||
<template #default="{ row }">
|
||||
<dict-tag :options="duty_time_type" :value="row.timeType" />
|
||||
<span>{{ row.parseTimeType }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="personName" label="值班人员姓名" />
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
<template>
|
||||
<el-dialog :title="form.id ? '编辑' : '新增'" v-model="visible" :close-on-click-modal="false" draggable>
|
||||
<el-form ref="dataFormRef" :model="form" :rules="dataRules" formDialogRef label-width="90px" v-loading="loading">
|
||||
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="类型" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入类型" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="唯一编号" prop="uniqueCode">
|
||||
<template #label>
|
||||
<span>唯一编号</span>
|
||||
<tip content="不输入会自动生成" />
|
||||
</template>
|
||||
<el-input v-model="form.uniqueCode" placeholder="请输入唯一编号" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col v-if="false" :span="24" class="mb20">
|
||||
<el-form-item label="类型" prop="bizType">
|
||||
<el-input v-model="form.bizType" placeholder="请输入类型" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="排序" prop="sort">
|
||||
<template #label>
|
||||
<span>排序</span>
|
||||
<tip content="越大越在前" />
|
||||
</template>
|
||||
<el-input-number :min="0" :step="1" v-model="form.sort" placeholder="" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="visible = false">取消</el-button>
|
||||
<el-button type="primary" @click="onSubmit" :disabled="loading">确认</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="SysDutyTypeDialog">
|
||||
import { useDict } from '/@/hooks/dict';
|
||||
import { useMessage } from "/@/hooks/message";
|
||||
import { rule } from '/@/utils/validate';
|
||||
const emit = defineEmits(['refresh']);
|
||||
|
||||
import * as sysDutyTypeApi from "/@/api/sys/sysDutyType";
|
||||
|
||||
// 定义变量内容
|
||||
const dataFormRef = ref();
|
||||
const visible = ref(false)
|
||||
const loading = ref(false)
|
||||
// 定义字典
|
||||
|
||||
// 提交表单数据
|
||||
const form = reactive({
|
||||
id: '',
|
||||
name: '',
|
||||
uniqueCode: '',
|
||||
bizType: '',
|
||||
sort: 0,
|
||||
});
|
||||
|
||||
// 定义校验规则
|
||||
const dataRules = ref({
|
||||
name: [{ required: true, message: '类型不能为空', trigger: 'blur' }],
|
||||
})
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = (id: string) => {
|
||||
visible.value = true
|
||||
form.id = ''
|
||||
|
||||
// 重置表单数据
|
||||
nextTick(() => {
|
||||
dataFormRef.value?.resetFields();
|
||||
});
|
||||
|
||||
// 获取sysDutyType信息
|
||||
if (id) {
|
||||
form.id = id
|
||||
getsysDutyTypeData(id)
|
||||
}
|
||||
};
|
||||
|
||||
// 提交
|
||||
const onSubmit = async () => {
|
||||
const valid = await dataFormRef.value.validate().catch(() => { });
|
||||
if (!valid) return false;
|
||||
|
||||
try {
|
||||
loading.value = true;
|
||||
form.id ? await sysDutyTypeApi.putObj(form) : await sysDutyTypeApi.addObj(form);
|
||||
useMessage().success(form.id ? '修改成功' : '添加成功');
|
||||
visible.value = false;
|
||||
emit('refresh');
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// 初始化表单数据
|
||||
const getsysDutyTypeData = (id: string) => {
|
||||
// 获取数据
|
||||
loading.value = true
|
||||
sysDutyTypeApi.getObj(id).then((res: any) => {
|
||||
Object.assign(form, res.data)
|
||||
}).finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
};
|
||||
|
||||
// 暴露变量
|
||||
defineExpose({
|
||||
openDialog
|
||||
});
|
||||
</script>
|
||||
@@ -1,13 +1,139 @@
|
||||
<!-- 值班类型 -->
|
||||
<template>
|
||||
<div class="layout-padding">
|
||||
<div class="layout-padding-auto layout-padding-view">
|
||||
<div class="layout-padding">
|
||||
<div class="layout-padding-auto layout-padding-view">
|
||||
<el-row>
|
||||
|
||||
<el-form :model="state.queryForm" ref="queryRef" :inline="true" @keyup.enter="getDataList">
|
||||
<el-form-item style="width: 250px;" label="类型名" prop="name">
|
||||
<el-input v-model="state.queryForm.name" placeholder="请输入类型名" />
|
||||
</el-form-item>
|
||||
<el-form-item style="width: 250px;" label="唯一编号" prop="uniqueCode">
|
||||
<el-input v-model="state.queryForm.uniqueCode" placeholder="请输入唯一编号" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button icon="search" type="primary" @click="getDataList">
|
||||
{{ $t('common.queryBtn') }}
|
||||
</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">{{ $t('common.resetBtn') }}</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<div class="mb8" style="width: 100%">
|
||||
<el-button icon="folder-add" type="primary" class="ml10" @click="formDialogRef.openDialog()"
|
||||
v-auth="'admin_sysDutyType_add'">
|
||||
新 增
|
||||
</el-button>
|
||||
<el-button plain :disabled="multiple" icon="Delete" type="primary" v-auth="'admin_sysDutyType_del'"
|
||||
@click="handleDelete(selectObjs)">
|
||||
删除
|
||||
</el-button>
|
||||
<right-toolbar v-model:showSearch="showSearch" :export="'admin_sysDutyType_export'" @exportExcel="exportExcel"
|
||||
class="ml10 mr20" style="float: right;" @queryTable="getDataList"></right-toolbar>
|
||||
</div>
|
||||
</el-row>
|
||||
<el-table :data="state.dataList" v-loading="state.loading" border :cell-style="tableStyle.cellStyle"
|
||||
:header-cell-style="tableStyle.headerCellStyle" @selection-change="selectionChangHandle"
|
||||
@sort-change="sortChangeHandle">
|
||||
<el-table-column type="selection" width="40" align="center" />
|
||||
<el-table-column type="index" label="#" width="40" />
|
||||
<el-table-column prop="bizType" label="分类">
|
||||
<template #default="{ row }">
|
||||
<dict-tag :options="sys_duty_type" :value="row.bizType" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="name" label="类型" />
|
||||
<el-table-column prop="uniqueCode" label="交接班唯一编号" show-overflow-tooltip />
|
||||
<el-table-column prop="sort" label="排序码" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="150">
|
||||
<template #default="scope">
|
||||
<el-button icon="edit-pen" text type="primary" v-auth="'admin_sysDutyType_edit'"
|
||||
@click="formDialogRef.openDialog(scope.row.id)">编辑</el-button>
|
||||
<el-button icon="delete" text type="primary" v-auth="'admin_sysDutyType_del'"
|
||||
@click="handleDelete([scope.row.id])">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
|
||||
</div>
|
||||
|
||||
<!-- 编辑、新增 -->
|
||||
<form-dialog ref="formDialogRef" @refresh="getDataList(false)" />
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="dutyType">
|
||||
<script setup lang="ts" name="systemSysDutyType">
|
||||
import { BasicTableProps, useTable } from "/@/hooks/table";
|
||||
import { useMessage, useMessageBox } from "/@/hooks/message";
|
||||
import { useDict } from '/@/hooks/dict';
|
||||
|
||||
</script>
|
||||
import * as sysDutyTypeApi from "/@/api/sys/sysDutyType";
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
const { sys_duty_type } = useDict("sys_duty_type")
|
||||
|
||||
// 引入组件
|
||||
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
|
||||
// 定义查询字典
|
||||
|
||||
// 定义变量内容
|
||||
const formDialogRef = ref()
|
||||
// 搜索变量
|
||||
const queryRef = ref()
|
||||
const showSearch = ref(true)
|
||||
// 多选变量
|
||||
const selectObjs = ref([]) as any
|
||||
const multiple = ref(true)
|
||||
|
||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
queryForm: {},
|
||||
pageList: sysDutyTypeApi.fetchList
|
||||
})
|
||||
|
||||
// table hook
|
||||
const {
|
||||
getDataList,
|
||||
currentChangeHandle,
|
||||
sizeChangeHandle,
|
||||
sortChangeHandle,
|
||||
downBlobFile,
|
||||
tableStyle
|
||||
} = useTable(state)
|
||||
|
||||
// 清空搜索条件
|
||||
const resetQuery = () => {
|
||||
// 清空搜索条件
|
||||
queryRef.value?.resetFields()
|
||||
// 清空多选
|
||||
selectObjs.value = []
|
||||
getDataList()
|
||||
}
|
||||
|
||||
// 导出excel
|
||||
const exportExcel = () => {
|
||||
downBlobFile('/admin/sysDutyType/export', Object.assign(state.queryForm, { ids: selectObjs }), 'sysDutyType.xlsx')
|
||||
}
|
||||
|
||||
// 多选事件
|
||||
const selectionChangHandle = (objs: { id: string }[]) => {
|
||||
selectObjs.value = objs.map(({ id }) => id);
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm('此操作将永久删除');
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await sysDutyTypeApi.delObjs(ids);
|
||||
getDataList();
|
||||
useMessage().success('删除成功');
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
Reference in new issue
Block a user