From 65f86f41dedbbbb7030e2f37ce3e001bbca4923a Mon Sep 17 00:00:00 2001
From: chengxiangling <291105840@qq.com>
Date: 星期四, 15 五月 2025 13:03:25 +0800
Subject: [PATCH] 查询日历带适用工厂
---
src/views/basicData/apsPlant/index.vue | 256 +++++++++++++++++++++++++++++++++++---------------
1 files changed, 178 insertions(+), 78 deletions(-)
diff --git a/src/views/basicData/apsPlant/index.vue b/src/views/basicData/apsPlant/index.vue
index 3fdb1f1..f1cc89a 100644
--- a/src/views/basicData/apsPlant/index.vue
+++ b/src/views/basicData/apsPlant/index.vue
@@ -1,37 +1,5 @@
<template>
<div class="app-container">
- <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
- <el-form-item label="宸ュ巶鍚嶇О" prop="plantName">
- <el-input
- v-model="queryParams.plantName"
- placeholder="璇疯緭鍏ュ伐鍘傚悕绉�"
- clearable
- @keyup.enter="handleQuery"
- />
- </el-form-item>
- <el-form-item label="宸ュ巶缂栫爜" prop="plantCode">
- <el-input
- v-model="queryParams.plantCode"
- placeholder="璇疯緭鍏ュ伐鍘傜紪鐮�"
- clearable
- @keyup.enter="handleQuery"
- />
- </el-form-item>
- <el-form-item label="鍚敤鐘舵��" prop="status">
- <el-select v-model="queryParams.status" placeholder="璇烽�夋嫨鍚敤鐘舵��" clearable>
- <el-option
- v-for="dict in aps_plant_status"
- :key="dict.value"
- :label="dict.label"
- :value="dict.value"
- />
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" icon="Search" @click="handleQuery">鎼滅储</el-button>
- <el-button icon="Refresh" @click="resetQuery">閲嶇疆</el-button>
- </el-form-item>
- </el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
@@ -40,7 +8,7 @@
plain
icon="Plus"
@click="handleAdd"
- v-hasPermi="['aps_plant:aps_plant:add']"
+ v-hasPermi="['plant:add']"
>鏂板</el-button>
</el-col>
<el-col :span="1.5">
@@ -50,10 +18,10 @@
icon="Edit"
:disabled="single"
@click="handleUpdate"
- v-hasPermi="['aps_plant:aps_plant:edit']"
+ v-hasPermi="['plant:edit']"
>淇敼</el-button>
</el-col>
- <el-col :span="1.5">
+<!-- <el-col :span="1.5">
<el-button
type="danger"
plain
@@ -62,59 +30,44 @@
@click="handleDelete"
v-hasPermi="['aps_plant:aps_plant:remove']"
>鍒犻櫎</el-button>
- </el-col>
+ </el-col>-->
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="Download"
@click="handleExport"
- v-hasPermi="['aps_plant:aps_plant:export']"
+ v-hasPermi="['plant:export']"
>瀵煎嚭</el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
- <el-table v-loading="loading" :data="aps_plantList" @selection-change="handleSelectionChange">
- <el-table-column type="selection" width="55" align="center" />
- <el-table-column label="宸ュ巶鍚嶇О" align="center" prop="plantName" />
- <el-table-column label="宸ュ巶缂栫爜" align="center" prop="plantCode" />
- <el-table-column label="鍚敤鐘舵��" align="center" prop="status">
- <template #default="scope">
- <dict-tag :options="aps_plant_status" :value="scope.row.status"/>
- </template>
- </el-table-column>
- <el-table-column label="鍒涘缓鑰�" align="center" prop="createBy" />
- <el-table-column label="鍒涘缓鏃堕棿" align="center" prop="createTime" />
- <el-table-column label="鏇存柊鑰�" align="center" prop="updateBy" />
- <el-table-column label="鏇存柊鏃堕棿" align="center" prop="updateTime" />
- <el-table-column label="鎿嶄綔" align="center" class-name="small-padding fixed-width">
- <template #default="scope">
- <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['aps_plant:aps_plant:edit']">淇敼</el-button>
- <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['aps_plant:aps_plant:remove']">鍒犻櫎</el-button>
- </template>
- </el-table-column>
- </el-table>
-
- <pagination
- v-show="total>0"
- :total="total"
- v-model:page="queryParams.pageNum"
- v-model:limit="queryParams.pageSize"
- @pagination="getList"
- />
+ <HxlhTable
+ style="width: 100%"
+ :columns="columns"
+ :data="aps_plantList"
+ :loading="loading"
+ :height="height"
+ :page="page"
+ @changePageNo="changePageNo"
+ @changePageSize="changePageSize"
+ @on-checkbox="handleCheckboxChange"
+ >
+ <template #buttons="{row}">
+ <vxe-button mode="text" @click="handleUpdate(row)" v-hasPermi="['plant:edit']" >缂栬緫</vxe-button>
+ </template>
+ </HxlhTable>
<!-- 娣诲姞鎴栦慨鏀瑰伐鍘傜鐞嗗璇濇 -->
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
<el-form ref="aps_plantRef" :model="form" :rules="rules" label-width="80px">
- <el-form-item label="id" prop="id">
- <el-input v-model="form.id" placeholder="璇疯緭鍏d" />
- </el-form-item>
+
<el-form-item label="宸ュ巶鍚嶇О" prop="plantName">
<el-input v-model="form.plantName" placeholder="璇疯緭鍏ュ伐鍘傚悕绉�" />
</el-form-item>
<el-form-item label="宸ュ巶缂栫爜" prop="plantCode">
- <el-input v-model="form.plantCode" placeholder="璇疯緭鍏ュ伐鍘傜紪鐮�" />
+ <el-input v-model="form.plantCode" placeholder="璇疯緭鍏ュ伐鍘傜紪鐮�" :disabled=disabled />
</el-form-item>
<el-form-item label="鍚敤鐘舵��" prop="status">
<el-radio-group v-model="form.status">
@@ -138,10 +91,14 @@
<script setup name="Aps_plant">
import { listAps_plant, getAps_plant, delAps_plant, addAps_plant, updateAps_plant } from "@/api/basicData/plant";
+import HxlhTable from '@/components/HxlhTable'
const { proxy } = getCurrentInstance();
const { aps_plant_status } = proxy.useDict('aps_plant_status');
-
+const height = ref(document.documentElement.clientHeight - 170 + "px;");
+const plantNameRules = ref(null);
+const plantCodeRules = ref(null);
+const dataForm = ref();
const aps_plantList = ref([]);
const open = ref(false);
const loading = ref(true);
@@ -149,9 +106,8 @@
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
-const total = ref(0);
const title = ref("");
-
+const disabled = ref(false);
const data = reactive({
form: {},
queryParams: {
@@ -162,20 +118,104 @@
status: null,
},
rules: {
- id: [
- { required: true, message: "id涓嶈兘涓虹┖", trigger: "blur" }
+ plantName: [
+ { required: true, message: "宸ュ巶鍚嶇О涓嶈兘涓虹┖", trigger: "blur" },
+ {
+ validator: async (rule, value, callback) => {
+ if (!value) {
+ return callback();
+ }
+ try {
+ if(value === plantNameRules.value){
+ callback();
+ }else{
+ const isExists = await checkPlantNameExists(value);
+ if (isExists) {
+ return callback(new Error('璇ュ伐鍘傚悕绉板凡瀛樺湪锛岃鏇存崲'));
+ } else {
+ callback();
+ }
+ }
+ } catch (error) {
+ return callback(new Error('鏍¢獙鐢ㄦ埛鍚嶆椂鍙戠敓閿欒锛岃绋嶅悗閲嶈瘯'));
+ }
+ },
+ trigger: 'blur'
+ }
+ ],
+ plantCode: [
+ { required: true, message: "宸ュ巶缂栫爜涓嶈兘涓虹┖", trigger: "blur" },
+ {
+ validator: async (rule, value, callback) => {
+ if (!value) {
+ return callback();
+ }
+ try {
+ if(value === plantCodeRules.value){
+ callback();
+ }else{
+ const isExists = await checkPlantCodeExists(value);
+ if (isExists) {
+ return callback(new Error('璇ュ伐鍘傜紪鐮佸凡瀛樺湪锛岃鏇存崲'));
+ } else {
+ callback();
+ }
+ }
+ } catch (error) {
+ return callback(new Error('鏍¢獙鐢ㄦ埛鍚嶆椂鍙戠敓閿欒锛岃绋嶅悗閲嶈瘯'));
+ }
+ },
+ trigger: 'blur'
+ }
+ ],
+ status: [
+ { required: true, message: "鍚敤鐘舵�佷笉鑳戒负绌�", trigger: "blur" },
],
}
});
const { queryParams, form, rules } = toRefs(data);
+// 鍒嗛〉灞炴��
+const page = ref({
+ total: 0,
+ current: 1,
+ size: 10
+});
+
+// 琛ㄦ牸閰嶇疆
+const columns = ref([
+ { type: 'checkbox', width: 60, align:"center"},
+ { type: 'seq', title: '搴忓彿', width: 60 },
+ {
+ title: '宸ュ巶鍚嶇О',
+ field: 'plantName',
+ },
+ {
+ title: '宸ュ巶缂栫爜',
+ field: 'plantCode',
+ },
+ {
+ title: '鍚敤鐘舵��',
+ field: 'status',
+ },
+ {
+ title: '鍒涘缓鑰�',
+ field: 'createBy',
+ },
+ {
+ title: '鍒涘缓鏃堕棿',
+ field: 'createTime',
+ },
+ { title: '鎿嶄綔', width: 100, fixed:"right", slots: { default: 'buttons' } }
+]);
+
/** 鏌ヨ宸ュ巶绠$悊鍒楄〃 */
function getList() {
loading.value = true;
listAps_plant(queryParams.value).then(response => {
aps_plantList.value = response.rows;
- total.value = response.total;
+ page.value.total = response.total;
loading.value = false;
});
}
@@ -199,10 +239,13 @@
updateTime: null
};
proxy.resetForm("aps_plantRef");
+ plantNameRules.value = null;
+ plantCodeRules.value = null;
}
/** 鎼滅储鎸夐挳鎿嶄綔 */
function handleQuery() {
+ page.value.current = 1;
queryParams.value.pageNum = 1;
getList();
}
@@ -225,22 +268,27 @@
reset();
open.value = true;
title.value = "娣诲姞宸ュ巶绠$悊";
+ disabled.value = false;
}
/** 淇敼鎸夐挳鎿嶄綔 */
function handleUpdate(row) {
reset();
const _id = row.id || ids.value
+ disabled.value = true;
getAps_plant(_id).then(response => {
+ dataForm.value = response.data;
form.value = response.data;
open.value = true;
title.value = "淇敼宸ュ巶绠$悊";
+ plantNameRules.value = form.value.plantName;
+ plantCodeRules.value = form.value.plantCode;
});
}
/** 鎻愪氦鎸夐挳 */
-function submitForm() {
- proxy.$refs["aps_plantRef"].validate(valid => {
+const submitForm = async () => {
+ await proxy.$refs["aps_plantRef"].validate(valid => {
if (valid) {
if (form.value.id != null) {
updateAps_plant(form.value).then(response => {
@@ -262,7 +310,7 @@
/** 鍒犻櫎鎸夐挳鎿嶄綔 */
function handleDelete(row) {
const _ids = row.id || ids.value;
- proxy.$modal.confirm('鏄惁纭鍒犻櫎宸ュ巶绠$悊缂栧彿涓�"' + _ids + '"鐨勬暟鎹」锛�').then(function() {
+ proxy.$modal.confirm('鏄惁纭鍒犻櫎宸ュ巶鏁版嵁锛�').then(function() {
return delAps_plant(_ids);
}).then(() => {
getList();
@@ -277,5 +325,57 @@
}, `aps_plant_${new Date().getTime()}.xlsx`)
}
+/** 妫�鏌ュ伐鍘傚悕瀛楅噸澶� */
+const checkPlantNameExists = async (value) => {
+ return new Promise((resolve) => {
+ queryParams.value = {};
+ queryParams.value.plantName = value;
+ listAps_plant(queryParams.value).then(response => {
+ if(response.total === 0){
+ resolve(false);
+ }else{
+ resolve(true);
+ }
+ });
+ queryParams.value = {};
+ });
+};
+
+/** 妫�鏌ュ伐鍘傜紪鐮侀噸澶� */
+const checkPlantCodeExists = async (value) => {
+ return new Promise((resolve) => {
+ queryParams.value = {};
+ queryParams.value.plantCode = value;
+ listAps_plant(queryParams.value).then(response => {
+ if(response.total === 0){
+ resolve(false);
+ }else{
+ resolve(true);
+ }
+ });
+ queryParams.value = {};
+ });
+};
+
+function changePageNo(currentPage) {
+ queryParams.value.pageNum = currentPage;
+ page.value.current = currentPage;
+ getList();
+}
+
+function changePageSize(pageSize) {
+ page.value.current = 1;
+ queryParams.value.pageNum = 1;
+ queryParams.value.pageSize = pageSize;
+ getList();
+}
+
+// 澶氶�夋閫変腑鏁版嵁
+const handleCheckboxChange = (data) => {
+ ids.value = data.records.map(item => item.id);
+ single.value = data.records.length != 1;
+ multiple.value = !data.records.length;
+};
+
getList();
</script>
--
Gitblit v1.9.3