liriming
2025-03-04 a484d883e1265f683dbf742b30799ca1324f5bd0
提交 | 用户 | 时间
d6fd1a 1 <template>
L 2   <!-- 搜索 -->
3   <ContentWrap>
4     <el-form
5       class="-mb-15px"
6       :model="queryParams"
7       ref="queryFormRef"
8       :inline="true"
9       label-width="68px"
10     >
11       <el-form-item label="模型代码" prop="modelCode">
12         <el-input
13           v-model="queryParams.modelCode"
14           placeholder="请输入模型代码"
15           clearable
16           @keyup.enter="handleQuery"
17           class="!w-240px"
18         />
19       </el-form-item>
20       <el-form-item label="模型名称" prop="modelName">
21         <el-input
22           v-model="queryParams.modelName"
23           placeholder="请输入模型名称"
24           clearable
25           @keyup.enter="handleQuery"
26           class="!w-240px"
27         />
28       </el-form-item>
29       <el-form-item>
30         <el-button @click="handleQuery">
31           <Icon icon="ep:search" class="mr-5px" />
32           搜索
33         </el-button>
34         <el-button @click="resetQuery">
35           <Icon icon="ep:refresh" class="mr-5px" />
36           重置
37         </el-button>
38         <el-button
39           type="primary"
40           plain
41           @click="openForm('create')"
42           v-hasPermi="['sche:adjust:create']"
43         >
44           <Icon icon="ep:plus" class="mr-5px" />
45           新增
46         </el-button>
47       </el-form-item>
48     </el-form>
49   </ContentWrap>
50
51   <!-- 列表 -->
52   <ContentWrap>
53     <el-table v-loading="loading" :data="list">
54       <el-table-column type="selection" header-align="center" align="center" fixed="left" width="50"/>
55       <el-table-column label="模型编码" align="center" prop="modelCode" min-width="100"/>
56       <el-table-column label="模型名称" header-align="center" align="left" prop="modelName" min-width="100"/>
57       <el-table-column label="状态" align="center" prop="status">
58         <template #default="scope">
a484d8 59           <dict-tag :type="DICT_TYPE.MODEL_STATUS" :value="scope.row.status" />
d6fd1a 60         </template>
L 61       </el-table-column>
62       <el-table-column label="备注" header-align="center" align="left" prop="remark" min-width="160" />
63       <el-table-column label="操作" align="center" min-width="100" fixed="right">
64         <template #default="scope">
65           <el-button
66             link
67             type="primary"
68             @click="openForm('update', scope.row.id)"
69             v-hasPermi="['sche:adjust:update']"
70           >
71             编辑
72           </el-button>
73           <el-button
74             link
75             type="primary"
76             @click="openResultList(scope.row.id)"
77           >
78             调整记录
79           </el-button>
80           <el-button
81             link
82             type="danger"
83             @click="handleDelete(scope.row.id)"
84             v-hasPermi="['sche:adjust:delete']"
85           >
86             删除
87           </el-button>
88         </template>
89       </el-table-column>
90     </el-table>
91     <!-- 分页 -->
92     <Pagination
93       :total="total"
94       v-model:page="queryParams.pageNo"
95       v-model:limit="queryParams.pageSize"
96       @pagination="getList"
97     />
98   </ContentWrap>
99
100   <!-- 表单弹窗:添加/修改 -->
101   <AdjustConfigForm ref="formRef" @success="getList" />
102
103   <!-- 表单弹窗:添加/修改 -->
104   <ResultList ref="resultRef" />
105 </template>
106 <script lang="ts" setup>
107 import * as AdjustConfigApi from '@/api/model/sche/adjust'
108 import AdjustConfigForm from './AdjustConfigForm.vue'
109 import ResultList from '@/views/model/sche/adjust/result/index.vue'
110 import {reactive} from "vue";
111 import {DICT_TYPE} from "@/utils/dict";
112
113 defineOptions({name: 'AdjustConfig'})
114
115 const message = useMessage() // 消息弹窗
116 const {t} = useI18n() // 国际化
117
118 const loading = ref(true) // 列表的加载中
119 const total = ref(0) // 列表的总页数
120 const list = ref([]) // 列表的数据
121 const queryParams = reactive({
122   pageNo: 1,
123   pageSize: 10,
124   modelCode: undefined,
125   modelName: undefined,
126   status: undefined,
127 })
128 const queryFormRef = ref() // 搜索的表单
129 const exportLoading = ref(false) // 导出的加载中
130
131 /** 查询列表 */
132 const getList = async () => {
133   loading.value = true
134   try {
135     const page = await AdjustConfigApi.getAdjustConfigPage(queryParams)
136     list.value = page.list
137     total.value = page.total
138   } finally {
139     loading.value = false
140   }
141 }
142
143 /** 搜索按钮操作 */
144 const handleQuery = () => {
145   queryParams.pageNo = 1
146   getList()
147 }
148
149 /** 重置按钮操作 */
150 const resetQuery = () => {
151   queryFormRef.value.resetFields()
152   handleQuery()
153 }
154
155 /** 添加/修改操作 */
156 const formRef = ref()
157 const openForm = (type: string, id?: number) => {
158   formRef.value.open(type, id)
159 }
160
161 /** 删除按钮操作 */
162 const handleDelete = async (id: number) => {
163   try {
164     // 删除的二次确认
165     await message.delConfirm()
166     // 发起删除
167     await AdjustConfigApi.deleteAdjustConfig(id)
168     message.success(t('common.delSuccess'))
169     // 刷新列表
170     await getList()
171   } catch {
172   }
173 }
174
175 /** 调用日志查看 */
176 const resultRef = ref()
177 const openResultList = (id?: string) => {
178   resultRef.value.open(id)
179 }
180 /** 初始化 **/
181 onMounted(async () => {
182   await getList()
183 })
184 </script>