|
|
@@ -0,0 +1,488 @@
|
|
|
+<script setup lang="ts" name="DeviceTask">
|
|
|
+import apis from "@a"
|
|
|
+import dayjs from "dayjs"
|
|
|
+
|
|
|
+const tableRef = ref()
|
|
|
+const modalRef = ref()
|
|
|
+const deviceSelectRef = ref()
|
|
|
+const selectType = ref("form")
|
|
|
+const opts = reactive({
|
|
|
+ columns: [
|
|
|
+ { field: "id", name: "任务ID", width: 100, isSort: true, visible: false, tooltip: true },
|
|
|
+ {
|
|
|
+ field: "taskName",
|
|
|
+ name: "任务名称",
|
|
|
+ visible: true,
|
|
|
+ isSort: false,
|
|
|
+ width: "auto",
|
|
|
+ tooltip: true
|
|
|
+ },
|
|
|
+ // {field: "taskType", name: "任务类型", visible: true, isSort: false, width: 100},
|
|
|
+ // {field: "cleanType", name: "清洁类型", visible: true, isSort: false, width: 100},
|
|
|
+ {
|
|
|
+ field: "deviceName",
|
|
|
+ name: "设备名称",
|
|
|
+ visible: true,
|
|
|
+ isSort: false,
|
|
|
+ width: "auto",
|
|
|
+ tooltip: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: "cycle",
|
|
|
+ name: "清消周期(单位:时)",
|
|
|
+ visible: true,
|
|
|
+ isSort: false,
|
|
|
+ width: 180,
|
|
|
+ tooltip: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: "executorName",
|
|
|
+ name: "执行责任人",
|
|
|
+ visible: true,
|
|
|
+ isSort: false,
|
|
|
+ width: 120,
|
|
|
+ tooltip: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: "acceptorName",
|
|
|
+ name: "验收责任人",
|
|
|
+ visible: true,
|
|
|
+ isSort: false,
|
|
|
+ width: 120,
|
|
|
+ tooltip: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: "lastCreateTime",
|
|
|
+ name: "上次创建时间",
|
|
|
+ visible: true,
|
|
|
+ isSort: false,
|
|
|
+ width: 140,
|
|
|
+ tooltip: true
|
|
|
+ },
|
|
|
+ { field: "status", name: "状态", visible: true, isSort: false, width: 80, tooltip: true },
|
|
|
+ { field: "startTime", name: "开始时间", visible: true, isSort: false, width: 140 },
|
|
|
+ { field: "endTime", name: "结束时间", visible: true, isSort: false, width: 140 },
|
|
|
+ { field: "actions", name: `操作`, width: 120 }
|
|
|
+ ] as any[],
|
|
|
+ queryParams: {
|
|
|
+ taskName: undefined,
|
|
|
+ taskType: 2,
|
|
|
+ cleanType: undefined,
|
|
|
+ deviceId: undefined,
|
|
|
+ deviceName: undefined,
|
|
|
+ status: undefined
|
|
|
+ },
|
|
|
+ searchFormItems: [
|
|
|
+ {
|
|
|
+ field: "taskName",
|
|
|
+ label: "任务名称",
|
|
|
+ class: "w-100",
|
|
|
+ required: false,
|
|
|
+ placeholder: "请输入任务名称",
|
|
|
+ component: "I",
|
|
|
+ listeners: {
|
|
|
+ keyup: (e: KeyboardEvent) => {
|
|
|
+ if (e.code == "Enter") {
|
|
|
+ handleQuery()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // {
|
|
|
+ // field: "taskType",
|
|
|
+ // label: "任务类型",
|
|
|
+ // class: "w-100",
|
|
|
+ // required: false,
|
|
|
+ // component: "Dict",
|
|
|
+ // props: {
|
|
|
+ // placeholder: "请选择任务类型",
|
|
|
+ // dictType: "device_task_type",
|
|
|
+ // valueIsNumber: 1,
|
|
|
+ // type: "select"
|
|
|
+ // },
|
|
|
+ // listeners: {
|
|
|
+ // change: () => {
|
|
|
+ // handleQuery()
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // field: "cleanType",
|
|
|
+ // label: "清洁类型",
|
|
|
+ // class: "w-100",
|
|
|
+ // required: false,
|
|
|
+ // component: "Dict",
|
|
|
+ // props: {
|
|
|
+ // placeholder: "请选择清洁类型",
|
|
|
+ // dictType: "device_clean_type",
|
|
|
+ // valueIsNumber: 1,
|
|
|
+ // type: "select"
|
|
|
+ // },
|
|
|
+ // listeners: {
|
|
|
+ // change: () => {
|
|
|
+ // handleQuery()
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ {
|
|
|
+ field: "deviceName",
|
|
|
+ label: "设备名称",
|
|
|
+ class: "w-100",
|
|
|
+ required: false,
|
|
|
+ placeholder: "请选择设备",
|
|
|
+ component: "I",
|
|
|
+ listeners: {
|
|
|
+ keyup: (e: KeyboardEvent) => {
|
|
|
+ if (e.code == "Enter") {
|
|
|
+ handleQuery()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ append: "icon",
|
|
|
+ appendClickFunc: () => {
|
|
|
+ handleOpenDeviceSelect("search")
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: "status",
|
|
|
+ label: "任务状态",
|
|
|
+ class: "w-100",
|
|
|
+ required: false,
|
|
|
+ placeholder: "请选择状态",
|
|
|
+ component: "Dict",
|
|
|
+ props: {
|
|
|
+ placeholder: "请选择状态",
|
|
|
+ dictType: "sys_normal_disable",
|
|
|
+ valueIsNumber: 1,
|
|
|
+ type: "select"
|
|
|
+ },
|
|
|
+ listeners: {
|
|
|
+ change: () => {
|
|
|
+ handleQuery()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ] as any,
|
|
|
+ permission: "device:deviceMaintenanceTask",
|
|
|
+ handleBtns: [],
|
|
|
+ handleFuns: {
|
|
|
+ handleCreate,
|
|
|
+ handleUpdate: () => {
|
|
|
+ const row = tableRef.value.getSelected()
|
|
|
+ handleUpdate(row)
|
|
|
+ },
|
|
|
+ handleDelete: () => {
|
|
|
+ const rows = tableRef.value.getSelecteds()
|
|
|
+ handleDelete(rows)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ customBtns: [],
|
|
|
+ tableListFun: apis.device.deviceTaskApi.list,
|
|
|
+ getEntityFun: apis.device.deviceTaskApi.get,
|
|
|
+ deleteEntityFun: apis.device.deviceTaskApi.del,
|
|
|
+ exportUrl: apis.device.deviceTaskApi.exportUrl,
|
|
|
+ exportName: "DeviceTask",
|
|
|
+ modalTitle: "设备清洁消毒任务",
|
|
|
+ formItems: [
|
|
|
+ {
|
|
|
+ field: "taskName",
|
|
|
+ label: "任务名称",
|
|
|
+ class: "w-100",
|
|
|
+ required: true,
|
|
|
+ placeholder: "请输入清消任务名称",
|
|
|
+ component: "I"
|
|
|
+ },
|
|
|
+ // {
|
|
|
+ // field: "taskType",
|
|
|
+ // label: "任务类型",
|
|
|
+ // class: "w-100",
|
|
|
+ // required: true,
|
|
|
+ // component: "Dict",
|
|
|
+ // props: {
|
|
|
+ // placeholder: "请选择任务类型",
|
|
|
+ // dictType: "device_task_type",
|
|
|
+ // type: "select",
|
|
|
+ // valueIsNumber: 1
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ {
|
|
|
+ field: "cleanType",
|
|
|
+ label: "清消类型",
|
|
|
+ class: "w-100",
|
|
|
+ required: true,
|
|
|
+ component: "Dict",
|
|
|
+ props: {
|
|
|
+ placeholder: "请选择清消类型",
|
|
|
+ dictType: "device_clean_type",
|
|
|
+ type: "select",
|
|
|
+ valueIsNumber: 1
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: "deviceName",
|
|
|
+ disabled: true,
|
|
|
+ label: "设备名称",
|
|
|
+ class: "w-100",
|
|
|
+ required: true,
|
|
|
+ placeholder: "请输入选择设备",
|
|
|
+ component: "I",
|
|
|
+ append: "icon",
|
|
|
+ appendClickFunc: () => {
|
|
|
+ handleOpenDeviceSelect("form")
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: "cycle",
|
|
|
+ label: "清消周期(单位:时)",
|
|
|
+ class: "w-100",
|
|
|
+ required: true,
|
|
|
+ placeholder: "请输入清消周期",
|
|
|
+ component: "I"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: "executorName",
|
|
|
+ disabled: true,
|
|
|
+ label: "执行责任人",
|
|
|
+ class: "w-100",
|
|
|
+ required: true,
|
|
|
+ placeholder: "请输入执行责任人",
|
|
|
+ component: "I",
|
|
|
+ append: "icon",
|
|
|
+ appendClickFunc: () => {
|
|
|
+ handleOpenUserSelect("executor")
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: "acceptorName",
|
|
|
+ disabled: true,
|
|
|
+ label: "验收责任人",
|
|
|
+ class: "w-100",
|
|
|
+ required: true,
|
|
|
+ placeholder: "请输入验收责任人",
|
|
|
+ component: "I",
|
|
|
+ append: "icon",
|
|
|
+ appendClickFunc: () => {
|
|
|
+ handleOpenUserSelect("acceptor")
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: "startTime",
|
|
|
+ label: "开始时间",
|
|
|
+ class: "w-100",
|
|
|
+ required: false,
|
|
|
+ component: "D",
|
|
|
+ props: {
|
|
|
+ placeholder: "请选择开始时间",
|
|
|
+ type: "datetime",
|
|
|
+ valueFormat: "YYYY-MM-DD HH:mm:ss"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: "endTime",
|
|
|
+ label: "结束时间",
|
|
|
+ class: "w-100",
|
|
|
+ required: false,
|
|
|
+ component: "D",
|
|
|
+ props: {
|
|
|
+ placeholder: "请选择结束时间",
|
|
|
+ type: "datetime",
|
|
|
+ valueFormat: "YYYY-MM-DD HH:mm:ss"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: "taskDesc",
|
|
|
+ label: "任务描述",
|
|
|
+ class: "w-100",
|
|
|
+ required: false,
|
|
|
+ placeholder: "请输入清消任务描述",
|
|
|
+ component: "I",
|
|
|
+ props: {
|
|
|
+ type: "textarea",
|
|
|
+ rows: 5
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ] as any,
|
|
|
+ resetForm: () => {
|
|
|
+ form.value = emptyFormData.value
|
|
|
+ },
|
|
|
+ labelWidth: "80px",
|
|
|
+ emptyFormData: {
|
|
|
+ id: undefined,
|
|
|
+ taskName: undefined,
|
|
|
+ taskDesc: undefined,
|
|
|
+ taskType: 2,
|
|
|
+ cleanType: undefined,
|
|
|
+ deviceId: undefined,
|
|
|
+ deviceName: undefined,
|
|
|
+ cycle: undefined,
|
|
|
+ executorId: undefined,
|
|
|
+ executorName: undefined,
|
|
|
+ acceptorId: undefined,
|
|
|
+ acceptorName: undefined,
|
|
|
+ status: 0,
|
|
|
+ endTime: undefined,
|
|
|
+ remark: undefined
|
|
|
+ }
|
|
|
+})
|
|
|
+const { queryParams, emptyFormData } = toRefs(opts)
|
|
|
+const form = ref<any>(emptyFormData.value)
|
|
|
+
|
|
|
+/** 搜索按钮操作 */
|
|
|
+function handleQuery(query?: any) {
|
|
|
+ query = query || tableRef.value?.getQueryParams() || queryParams.value
|
|
|
+ addDateRange(query, query.dateRangeEndTime, "EndTime")
|
|
|
+ addDateRange(query, query.dateRangeCreateTime)
|
|
|
+ addDateRange(query, query.dateRangeUpdateTime, "UpdateTime")
|
|
|
+ tableRef.value?.query(query)
|
|
|
+}
|
|
|
+
|
|
|
+/** 重置按钮操作 */
|
|
|
+function resetQuery(query?: any) {
|
|
|
+ query = query || tableRef.value?.getQueryParams() || queryParams.value
|
|
|
+ query.dateRangeEndTime = [] as any
|
|
|
+ addDateRange(query, query.dateRangeEndTime, "EndTime")
|
|
|
+ query.dateRangeCreateTime = [] as any
|
|
|
+ addDateRange(query, query.dateRangeCreateTime)
|
|
|
+ //
|
|
|
+}
|
|
|
+function handleCreate() {
|
|
|
+ tableRef.value.defaultHandleFuns.handleCreate()
|
|
|
+}
|
|
|
+/** 修改按钮操作 */
|
|
|
+function handleUpdate(row: any) {
|
|
|
+ tableRef.value.defaultHandleFuns.handleUpdate("", row)
|
|
|
+}
|
|
|
+
|
|
|
+/** 删除按钮操作 */
|
|
|
+function handleDelete(rows: any[]) {
|
|
|
+ tableRef.value.defaultHandleFuns.handleDelete("", rows)
|
|
|
+}
|
|
|
+
|
|
|
+/** 提交按钮 */
|
|
|
+function submitForm() {
|
|
|
+ apis.device.deviceTaskApi.addOrUpdate(form.value).then(() => {
|
|
|
+ handleQuery()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+function handleOpenDeviceSelect(type: string) {
|
|
|
+ selectType.value = type
|
|
|
+ if (selectType.value === "search") {
|
|
|
+ queryParams.value.deviceId = undefined
|
|
|
+ queryParams.value.deviceName = ""
|
|
|
+ tableRef.value.setQueryParams(queryParams.value)
|
|
|
+ }
|
|
|
+ deviceSelectRef.value.open()
|
|
|
+}
|
|
|
+function onDeviceSelectConfirm(data: any) {
|
|
|
+ if (selectType.value === "form") {
|
|
|
+ form.value.deviceId = data[0].id
|
|
|
+ form.value.deviceName = data[0].name
|
|
|
+ } else if (selectType.value === "search") {
|
|
|
+ queryParams.value.deviceId = data[0].id
|
|
|
+ queryParams.value.deviceName = data[0].name
|
|
|
+ handleQuery(queryParams.value)
|
|
|
+ }
|
|
|
+}
|
|
|
+const userSelectRef = ref()
|
|
|
+const selectUserType = ref("")
|
|
|
+function handleOpenUserSelect(type: string) {
|
|
|
+ selectUserType.value = type
|
|
|
+ userSelectRef.value.open()
|
|
|
+}
|
|
|
+function onUserSelectConfirm(data) {
|
|
|
+ if (selectUserType.value === "executor") {
|
|
|
+ form.value.executorId = data[0].userId
|
|
|
+ form.value.executorName = data[0].nickName
|
|
|
+ } else if (selectUserType.value === "acceptor") {
|
|
|
+ form.value.acceptorId = data[0].userId
|
|
|
+ form.value.acceptorName = data[0].nickName
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+<template>
|
|
|
+ <div class="app-container">
|
|
|
+ <VbDataTable
|
|
|
+ ref="tableRef"
|
|
|
+ keyField="id"
|
|
|
+ :columns="opts.columns"
|
|
|
+ :handle-perm="opts.permission"
|
|
|
+ :handle-btns="opts.handleBtns"
|
|
|
+ :handle-funs="opts.handleFuns"
|
|
|
+ :search-form-items="opts.searchFormItems"
|
|
|
+ :custom-btns="opts.customBtns"
|
|
|
+ :remote-fun="opts.tableListFun"
|
|
|
+ :get-entity-fun="opts.getEntityFun"
|
|
|
+ :delete-entity-fun="opts.deleteEntityFun"
|
|
|
+ :export-url="opts.exportUrl"
|
|
|
+ :export-name="opts.exportName"
|
|
|
+ :modal="modalRef"
|
|
|
+ :reset-form-fun="opts.resetForm"
|
|
|
+ v-model:form-data="form"
|
|
|
+ v-model:query-params="queryParams"
|
|
|
+ :check-multiple="true"
|
|
|
+ :reset-search-form-fun="resetQuery"
|
|
|
+ :custom-search-fun="handleQuery">
|
|
|
+ <template #taskType="{ row }">
|
|
|
+ <DictTag type="device_task_type" :value-is-number="1" :value="row.taskType"></DictTag>
|
|
|
+ </template>
|
|
|
+ <template #cleanType="{ row }">
|
|
|
+ <DictTag type="device_clean_type" :value-is-number="1" :value="row.cleanType"></DictTag>
|
|
|
+ </template>
|
|
|
+ <template #status="{ row }">
|
|
|
+ <DictTag type="sys_normal_disable" :value-is-number="1" :value="row.status"></DictTag>
|
|
|
+ </template>
|
|
|
+ <template #lastCreateTime="{ row }">
|
|
|
+ <template v-if="row.lastCreateTime">
|
|
|
+ {{ dayjs(row.lastCreateTime).format("YYYY-MM-DD HH:mm:ss") }}
|
|
|
+ </template>
|
|
|
+ <span v-else>-</span>
|
|
|
+ </template>
|
|
|
+ <template #startTime="{ row }">
|
|
|
+ <template v-if="row.startTime">
|
|
|
+ {{ dayjs(row.startTime).format("YYYY-MM-DD HH:mm:ss") }}
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ <template #endTime="{ row }">
|
|
|
+ <template v-if="row.endTime">
|
|
|
+ {{ dayjs(row.endTime).format("YYYY-MM-DD HH:mm:ss") }}
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ <template #actions="{ row }">
|
|
|
+ <vb-tooltip content="修改" placement="top">
|
|
|
+ <el-button
|
|
|
+ link
|
|
|
+ type="primary"
|
|
|
+ @click="handleUpdate(row)"
|
|
|
+ v-hasPermission="'device:deviceTask:edit'">
|
|
|
+ <template #icon>
|
|
|
+ <VbIcon icon-name="notepad-edit" icon-type="duotone" class="fs-3"></VbIcon>
|
|
|
+ </template>
|
|
|
+ </el-button>
|
|
|
+ </vb-tooltip>
|
|
|
+ <vb-tooltip content="删除" placement="top">
|
|
|
+ <el-button
|
|
|
+ link
|
|
|
+ type="primary"
|
|
|
+ @click="handleDelete([row])"
|
|
|
+ v-hasPermission="'device:deviceTask:remove'">
|
|
|
+ <template #icon>
|
|
|
+ <VbIcon icon-name="trash-square" icon-type="duotone" class="fs-3"></VbIcon>
|
|
|
+ </template>
|
|
|
+ </el-button>
|
|
|
+ </vb-tooltip>
|
|
|
+ </template>
|
|
|
+ </VbDataTable>
|
|
|
+ <VbModal
|
|
|
+ v-model:modal="modalRef"
|
|
|
+ :title="opts.modalTitle"
|
|
|
+ :form-data="form"
|
|
|
+ :form-items="opts.formItems"
|
|
|
+ :label-width="opts.labelWidth"
|
|
|
+ append-to-body
|
|
|
+ @confirm="submitForm"></VbModal>
|
|
|
+
|
|
|
+ <DeviceSelect ref="deviceSelectRef" @confirm="onDeviceSelectConfirm"></DeviceSelect>
|
|
|
+ <UserSelect ref="userSelectRef" :multiple="false" @confirm="onUserSelectConfirm"></UserSelect>
|
|
|
+ </div>
|
|
|
+</template>
|