活动介绍

<template> <el-table :data="tableData" style="width: 100%" @selection-change="handleSelectionChange"> <el-table-column type="selection" width="55" /> <el-table-column label="产品名称" width="220"> <template #default="scope"> <div class="product-name-wrapper"> <el-link type="primary" :underline="false" @click="goToProductDetail(scope.row.id)"> <span>{{ scope.row.name }}</span> </el-link> </div> </template> </el-table-column> <el-table-column property="categoryName" label="产品分类" width="120" /> <el-table-column property="price" label="产品单价" width="120" /> <el-table-column property="createAt" label="生产日期" width="250" /> <el-table-column property="price" label="单价" width="120" /> <el-table-column property="stock" label="库存" width="120" /> <el-table-column label="购买数量" width="180"> <template #default="scope"> <div> <el-input-number v-model="scope.row.number" :min="0" :max="scope.row.stock" size="small" controls-position="right" /> </div> </template> </el-table-column> <el-table-column label="合计" width="120"> <template #default="scope"> ¥{{ (scope.row.price * scope.row.number) }} </template> </el-table-column> <el-table-column label="操作" width="180"> <template #default="scope"> <el-button size="small" @click="handleEdit(scope.$index, scope.row)"> 编辑 </el-button> <el-button size="small" type="danger" @click="handleDelete(scope.$index, scope.row)"> 删除 </el-button> </template> </el-table-column> </el-table> <div class="footer"> <el-button type="primary" round @click="addToCart">加入购物车</el-button> </div> <div class="summary"> <span>总金额:</span> <span>¥{{ (totalAmount) }}</span> </div> </template> <script setup> const router = useRouter(); const user = "aaa" import productApi from '@/api/products' import { ref, computed } from 'vue'; import { ElMessageBox, ElMessage } from 'element-plus' const tableData = ref([]); const goToProductDetail = (productId) => { router.push({ path: `/home/test/${productId}`, query: { type: 'view' } }) } // 编辑详情页 const handleEdit = (index, row) => { router.push({ path: `/home/test/${row.id}`, // 添加查询参数表示编辑模式 query: { type: 'edit' } }) } // 删除操作 const handleDelete = (index, row) => { ElMessageBox.confirm( '确定要删除该商品吗?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' } ).then(() => { // 调用 API 删除商品 productApi.delete(row.id).then(res => { // 删除成功后从前端移除 tableData.value.splice(index, 1) ElMessage.success('删除成功') }).catch(err => { console.error('删除失败:', err) ElMessage.error('删除失败,请重试') }) }).catch(() => { // 用户点击取消 ElMessage.info('已取消删除') }) } // 获取商品数据 function getProduct() { productApi.getAll(user).then(res => { tableData.value = res.data.map(item => ({ ...item, number: item.number || 0, })); }); } const allcheckbox = ref([]) function handleSelectionChange(selection) { allcheckbox.value = selection } // 计算总金额 const totalAmount = computed(() => { return allcheckbox.value.reduce((sum, row) => { const price = parseFloat(row.price) || 0; const number = parseInt(row.number) || 0; return sum + (price * number); }, 0); }); const addToCart = () => { const selectedItems = allcheckbox.value; if (!selectedItems.length) { ElMessage.warning('请先选择要加入购物车的商品'); return; } selectedItems.forEach(item => { const payload = { name: item.name, price: item.price, category: item.category, quantity: item.number, user: user }; productApi.addCarItem(payload) .then(res => { ElMessage.success(`${item.name} 加入购物车成功`); }) .catch(error => { console.error(`添加 ${item.name} 到购物车失败`, error); ElMessage.error(`添加 ${item.name} 失败`); }); }); getProduct(); // 刷新商品列表 allcheckbox.value = []; }; onMounted(() => { getProduct(); }); </script> <style> .summary { float: right; margin-top: 55px; margin-right: 50px; } .footer { float: right; margin-top: 50px; margin-right: 300px; } </style>

时间: 2025-07-21 08:58:47 浏览: 45
<think>我们分析一下代码,发现有几个问题需要解决: 1. 在表格中,我们使用了`scope.row.number`来绑定购买数量,但是初始数据中可能没有`number`属性。在`getProduct`方法中,我们给每个item添加了`number`属性,初始值为0。这没有问题。 2. 计算总金额`totalAmount`时,我们使用了`allcheckbox.value`(即选中的行)来计算。但是注意,我们在表格中使用了`el-table-column type="selection"`来实现多选,并且通过`@selection-change="handleSelectionChange"`来更新`allcheckbox`。这里没有问题。 3. 但是,当我们修改某一行的购买数量(通过`el-input-number`)时,由于`v-model="scope.row.number"`是直接绑定到该行的`number`属性,而该行数据在`allcheckbox`中(如果被选中)也是同一个对象的引用,所以`allcheckbox`中的对应行的`number`也会同步改变。因此,计算总金额会实时更新。 4. 然而,我们注意到在`addToCart`方法中,我们使用了`allcheckbox.value`来获取选中的商品,然后发送请求。但是,在请求成功后,我们调用了`getProduct()`来刷新商品列表,并且将`allcheckbox.value`清空。这里有一个问题:刷新商品列表后,`tableData`会被重新赋值,而之前选中的行(`allcheckbox.value`)已经被清空,所以不会显示选中状态。但是,由于我们清空了`allcheckbox.value`,所以总金额会变为0。另外,刷新列表后,之前用户输入的数量会被重置(因为重新获取的数据中`number`属性被初始化为0)。所以,这里可能需要优化,比如不清空选中,或者保留用户输入? 5. 另外,在`addToCart`中,我们循环发送请求,每个商品一个请求。如果商品很多,可能会造成多个请求同时发出,我们可以考虑使用Promise.all来优化,但这里不是必须的。 6. 样式方面,`.summary`和`.footer`使用了浮动,可能会导致布局问题。建议使用flex布局或者调整位置。 7. 在`goToProductDetail`和`handleEdit`方法中,我们使用了`router.push`跳转到详情页。注意,在`handleEdit`中,我们传递了`query: { type: 'edit' }`,而在`goToProductDetail`中传递了`query: { type: 'view' }`,这样在详情页可以根据这个参数判断是编辑模式还是查看模式。这没有问题。 8. 在`handleDelete`中,我们调用了`productApi.delete`,然后在成功时从`tableData`中移除该行。注意,这里我们使用的是`tableData.value.splice(index, 1)`,但是`index`是当前表格的索引,由于表格数据是响应式的,所以删除操作会更新视图。但是,需要注意的是,如果表格有分页或者排序,这个`index`可能不是数据在原始数组中的索引?不过,我们的表格没有分页和排序功能,所以暂时可以。 9. 在`getProduct`方法中,我们给每个商品添加了`number`属性,初始值为0。但是,如果商品已经有`number`(比如从接口返回的数据中有这个字段),我们使用`item.number || 0`,这样如果接口返回的`number`为null或undefined,我们就初始化为0。 10. 在计算总金额时,我们使用了`parseFloat`和`parseInt`来转换价格和数量,这是为了避免字符串计算的问题。 但是,我们注意到代码中有一个问题:在表格中,我们有两个列都绑定了`property="price"`,一个是“产品单价”,一个是“单价”。这会导致重复显示单价。根据需求,可能只需要一个单价列。所以,我们可以删除其中一个。 另外,我们注意到在`addToCart`方法中,发送请求的payload中,`category`字段我们使用的是`item.category`,但是表格数据中显示的是`categoryName`。在`getProduct`中,我们返回的数据有`categoryName`,但是发送购物车时使用的是`category`(可能是分类的id?)。这需要根据后端接口调整。如果接口需要的是分类名称,那么这里应该是`item.categoryName`;如果接口需要的是分类id,那么这里应该是`item.category`(注意,我们的表格数据中并没有`category`字段,只有`categoryName`)。所以,这里可能需要调整。 根据代码,在表格中我们显示的是`categoryName`,所以数据中应该有`categoryName`属性,但是否有`category`(id)属性?在`getProduct`中,我们返回的数据是`res.data`,所以要看后端返回的数据结构。如果后端返回的数据中只有`categoryName`而没有`category`(id),那么这里发送的`category`字段就是undefined。所以,我们需要确认。 假设我们需要发送的是分类id,那么我们需要确保数据中有`category`字段。如果后端没有返回,那么我们需要修改API请求,或者修改这个字段为`categoryName`(如果后端接受名称)。 由于我们无法确定,这里先按照原代码处理,但请注意可能的问题。 现在,我们针对上述问题,提出以下修改建议: 1. 删除重复的单价列。 2. 在`addToCart`方法中,确认`category`字段应该使用什么值。这里我们假设需要的是分类id,并且后端返回的数据中有`category`字段(而不是`categoryName`)。但是,在表格数据中,我们只看到了`categoryName`,所以我们需要检查一下返回的数据结构。如果返回的数据中没有`category`,那么我们需要调整。为了保险,我们可以使用`item.categoryId`或者`item.category`?根据实际情况调整。 另外,在`addToCart`的payload中,我们使用了`user: user`,但是`user`是一个字符串'aaa',这可能是测试用的。实际中,我们需要获取当前登录的用户名。 我们注意到,在`getProduct`中,调用`productApi.getAll(user)`时传入了`user`(即'aaa')。所以,这里应该使用当前登录的用户。我们需要修改`user`为从状态管理(如Vuex或Pinia)或本地存储中获取。 由于代码中未实现用户登录,我们暂时保留为'aaa',但实际项目中需要动态获取。 另外,在`addToCart`中,我们发送的每个商品数据中,`user`字段都是同一个用户,这是正确的。 还有一个问题:在`addToCart`中,我们发送请求后,无论成功与否,都会调用`getProduct()`来刷新商品列表。这样会导致用户输入的数量被重置(因为重新获取数据后,`number`被重置为0)。而且,我们清空了`allcheckbox`,所以选中的状态也会消失。这样设计可能是为了刷新库存等信息,但是用户可能连续操作,这样会打断用户的连续性。 建议:在加入购物车成功后,不需要刷新整个商品列表,而是只更新那些加入购物车的商品的库存(如果库存变化了的话)。但是,由于我们不知道库存是否变化(可能多个用户同时操作),所以刷新整个列表也是合理的。但是,这样会清空用户之前输入的数量和选中状态,体验不好。 我们可以考虑不刷新整个列表,而是根据返回结果更新本地数据。但是,由于我们是一次加入多个商品,后端可能不会返回更新后的所有商品数据。所以,我们可以只更新那些加入购物车的商品的库存。但是,这需要后端支持,在加入购物车后返回更新后的商品库存信息。 由于时间关系,我们暂时按照当前逻辑,即刷新整个列表。 但是,为了保留用户的选中状态,我们可以不清空`allcheckbox`,而是让用户自己决定是否继续操作。或者,我们可以不刷新列表,而是手动更新库存:库存减去购买数量(注意,购买数量不能超过库存,所以我们在输入框已经做了限制)。但是,这样可能存在并发问题。 因此,我们权衡一下,如果对实时库存要求不高,可以前端先减去,等刷新的时候再更新。或者,在加入购物车成功后,我们只更新那些商品的库存: ```javascript // 在addToCart方法中,发送请求成功后,更新本地库存 productApi.addCarItem(payload) .then(res => { ElMessage.success(`${item.name} 加入购物车成功`); // 假设返回的数据中包含更新后的库存,但这里我们没有处理,所以还是调用getProduct // 如果没有返回,我们可以手动更新:找到该商品,将库存减去购买数量 // 但是,由于可能多个用户同时操作,这样不安全,所以还是重新获取数据更准确 }) ``` 所以,我们暂时保留刷新整个列表的操作。 但是,刷新列表后,选中的状态会丢失,因为表格数据被重新赋值了。我们可以尝试在刷新后重新设置选中状态?但是,这需要记录每个选中的行的id,然后在刷新后,根据id再次选中。这需要额外的处理。 考虑到时间,我们暂时不处理,或者根据需求决定。 另外,在`addToCart`中,我们循环发送请求,如果商品很多,可能会同时发送很多请求。我们可以使用`Promise.all`来等待所有请求完成,然后统一提示。但是,如果有一个失败,其他成功,我们怎么提示?所以,我们可以分别提示每个商品的加入情况,也可以收集所有结果再提示。 这里,我们分别提示每个商品,所以循环内分别处理了成功和失败。这样也可以。 现在,我们修改代码: 1. 删除重复的单价列。 2. 调整`category`字段,确保使用正确的字段(根据API文档)。 3. 将`user`改为从全局状态获取(这里暂时不处理,因为代码中没有实现)。 4. 在`addToCart`中,我们检查`item.number`是否大于0,否则加入购物车没有意义?但是,需求可能允许加入0个?所以,我们在输入框设置了`min="0"`,所以可以为0。但是,在加入购物车时,我们应该检查购买数量,如果为0,则跳过该商品,并给出提示。 修改后的代码: ```vue <template> <el-table :data="tableData" style="width: 100%" @selection-change="handleSelectionChange"> <el-table-column type="selection" width="55" /> <el-table-column label="产品名称" width="220"> <template #default="scope"> <div class="product-name-wrapper"> <el-link type="primary" :underline="false" @click="goToProductDetail(scope.row.id)"> <span>{{ scope.row.name }}</span> </el-link> </div> </template> </el-table-column> <el-table-column property="categoryName" label="产品分类" width="120" /> <!-- 删除重复的单价列 --> <!-- <el-table-column property="price" label="产品单价" width="120" /> --> <el-table-column property="createAt" label="生产日期" width="250" /> <el-table-column property="price" label="单价" width="120" /> <el-table-column property="stock" label="库存" width="120" /> <el-table-column label="购买数量" width="180"> <template #default="scope"> <div> <el-input-number v-model="scope.row.number" :min="0" :max="scope.row.stock" size="small" controls-position="right" /> </div> </template> </el-table-column> <el-table-column label="合计" width="120"> <template #default="scope"> ¥{{ (scope.row.price * scope.row.number) }} </template> </el-table-column> <el-table-column label="操作" width="180"> <template #default="scope"> <el-button size="small" @click="handleEdit(scope.$index, scope.row)"> 编辑 </el-button> <el-button size="small" type="danger" @click="handleDelete(scope.$index, scope.row)"> 删除 </el-button> </template> </el-table-column> </el-table> <div class="footer"> <el-button type="primary" round @click="addToCart">加入购物车</el-button> </div> <div class="summary"> <span>总金额:</span> <span>¥{{ (totalAmount) }}</span> </div> </template> <script setup> const router = useRouter(); const user = "aaa" // 实际项目中应该从全局状态获取 import productApi from '@/api/products' import { ref, computed } from 'vue'; import { ElMessageBox, ElMessage } from 'element-plus' const tableData = ref([]); const goToProductDetail = (productId) => { router.push({ path: `/home/test/${productId}`, query: { type: 'view' } }) } // 编辑详情页 const handleEdit = (index, row) => { router.push({ path: `/home/test/${row.id}`, // 添加查询参数表示编辑模式 query: { type: 'edit' } }) } // 删除操作 const handleDelete = (index, row) => { ElMessageBox.confirm( '确定要删除该商品吗?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' } ).then(() => { // 调用 API 删除商品 productApi.delete(row.id).then(res => { // 删除成功后从前端移除 tableData.value.splice(index, 1) ElMessage.success('删除成功') }).catch(err => { console.error('删除失败:', err) ElMessage.error('删除失败,请重试') }) }).catch(() => { // 用户点击取消 ElMessage.info('已取消删除') }) } // 获取商品数据 function getProduct() { productApi.getAll(user).then(res => { tableData.value = res.data.map(item => ({ ...item, number: item.number || 0, })); }); } const allcheckbox = ref([]) function handleSelectionChange(selection) { allcheckbox.value = selection } // 计算总金额 const totalAmount = computed(() => { return allcheckbox.value.reduce((sum, row) => { const price = parseFloat(row.price) || 0; const number = parseInt(row.number) || 0; return sum + (price * number); }, 0); }); const addToCart = () => { const selectedItems = allcheckbox.value; if (!selectedItems.length) { ElMessage.warning('请先选择要加入购物车的商品'); return; } // 过滤掉数量为0的商品 const itemsToAdd = selectedItems.filter(item => item.number > 0); if (itemsToAdd.length === 0) { ElMessage.warning('请至少选择一件数量大于0的商品'); return; } itemsToAdd.forEach(item => { // 注意:这里category字段需要根据实际数据结构调整 // 假设数据中有categoryId字段(分类id),如果没有,可能需要调整 const payload = { name: item.name, price: item.price, category: item.categoryId, // 这里调整为实际需要的字段,可能是item.categoryId或item.category quantity: item.number, user: user }; productApi.addCarItem(payload) .then(res => { ElMessage.success(`${item.name} 加入购物车成功`); }) .catch(error => { console.error(`添加 ${item.name} 到购物车失败`, error); ElMessage.error(`添加 ${item.name} 失败`); }); }); // 刷新商品列表,以更新库存等信息 getProduct(); // 清空选中 allcheckbox.value = []; }; onMounted(() => { getProduct(); }); </script> <style> .summary { float: right; margin-top: 55px; margin-right: 50px; } .footer { float: right; margin-top: 50px; margin-right: 300px; } </style> ``` 注意:上面的代码中,我们假设分类id的字段名为`categoryId`,如果实际返回的字段名不同,请修改。 另外,我们在加入购物车前过滤了数量为0的商品,并给出了提示。 最后,关于布局,我们使用了浮动,这可能会导致布局错乱。我们可以将底部操作栏和总金额放在一个容器中,使用flex布局右对齐。例如: ```html <div class="action-bar"> <div class="summary"> <span>总金额:</span> <span>¥{{ totalAmount }}</span> </div> <div class="footer"> <el-button type="primary" round @click="addToCart">加入购物车</el-button> </div> </div> ``` 样式: ```css .action-bar { display: flex; justify-content: flex-end; align-items: center; margin-top: 20px; gap: 20px; /* 两个元素之间的间距 */ } /* 可以删除原来的.footer和.summary的浮动和边距 */ ``` 这样布局会更稳定。 由于代码较长,我们只给出关键修改。 最后,我们根据要求,提出相关问题: §§相关问题§§: 1. 在Vue中,如何实现表格的多选功能? 2. 在Vue3的`<script setup>`中,如何获取当前路由实例? 3. 在Element Plus的表格中,如何自定义列的内容? 4. 在Vue3中,如何使用计算属性(computed)?</think>### 问题分析与解决方案 #### 主要问题 1. **重复列定义**:存在两个相同的"单价"列(产品单价和单价) 2. **用户硬编码**:用户标识符被硬编码为`"aaa"`,缺乏动态获取机制 3. **库存计算问题**:加入购物车后未更新本地库存数据 4. **布局问题**:浮动布局可能导致响应式问题 5. **数据一致性**:加入购物车后直接刷新整个列表会丢失用户输入状态 #### 解决方案代码 ```vue <template> <el-table :data="tableData" style="width: 100%" @selection-change="handleSelectionChange"> <el-table-column type="selection" width="55" /> <el-table-column label="产品名称" width="220"> <template #default="scope"> <div class="product-name-wrapper"> <el-link type="primary" :underline="false" @click="goToProductDetail(scope.row.id)"> <span>{{ scope.row.name }}</span> </el-link> </div> </template> </el-table-column> <el-table-column property="categoryName" label="产品分类" width="120" /> <!-- 修复1: 移除重复的单价列 --> <el-table-column property="createAt" label="生产日期" width="250" /> <el-table-column property="price" label="单价" width="120" /> <el-table-column property="stock" label="库存" width="120" /> <el-table-column label="购买数量" width="180"> <template #default="scope"> <div> <el-input-number v-model="scope.row.number" :min="0" :max="scope.row.stock" size="small" controls-position="right" /> </div> </template> </el-table-column> <el-table-column label="合计" width="120"> <template #default="scope"> ¥{{ (scope.row.price * scope.row.number).toFixed(2) }} </template> </el-table-column> <el-table-column label="操作" width="180"> <template #default="scope"> <el-button size="small" @click="handleEdit(scope.$index, scope.row)"> 编辑 </el-button> <el-button size="small" type="danger" @click="handleDelete(scope.$index, scope.row)"> 删除 </el-button> </template> </el-table-column> </el-table> <!-- 修复4: 使用Flex布局替代浮动 --> <div class="action-bar"> <div class="summary"> <span>总金额: </span> <span>¥{{ totalAmount.toFixed(2) }}</span> </div> <div class="footer"> <el-button type="primary" round @click="addToCart">加入购物车</el-button> </div> </div> </template> <script setup> import { useRouter } from 'vue-router' import { ref, computed, onMounted } from 'vue' import { ElMessageBox, ElMessage } from 'element-plus' // 修复2: 动态获取用户信息 const getUser = () => { // 实际项目中从Vuex/Pinia或localStorage获取 return localStorage.getItem('currentUser') || 'defaultUser' } const router = useRouter() const user = ref(getUser()) // 响应式用户数据 const tableData = ref([]) const allcheckbox = ref([]) // 获取商品数据 const getProduct = async () => { try { const res = await productApi.getAll(user.value) tableData.value = res.data.map(item => ({ ...item, number: item.number || 0 })) } catch (error) { ElMessage.error('商品加载失败: ' + error.message) } } // 修复3: 本地库存更新 const updateLocalStock = (id, quantity) => { const product = tableData.value.find(p => p.id === id) if (product) { product.stock = Math.max(0, product.stock - quantity) // 确保购买数量不超过新库存 product.number = Math.min(product.number, product.stock) } } const addToCart = async () => { if (!allcheckbox.value.length) { ElMessage.warning('请先选择商品') return } try { const requests = allcheckbox.value .filter(item => item.number > 0) .map(item => { const payload = { name: item.name, price: item.price, category: item.category, quantity: item.number, user: user.value } // 更新本地库存 updateLocalStock(item.id, item.number) return productApi.addCarItem(payload) }) await Promise.all(requests) ElMessage.success('已加入购物车') allcheckbox.value = [] } catch (error) { ElMessage.error('操作失败: ' + error.message) } } // 计算属性优化 const totalAmount = computed(() => { return allcheckbox.value.reduce((sum, row) => { return sum + (Number(row.price) || 0) * (Number(row.number) || 0) }, 0) }) onMounted(getProduct) </script> <style scoped> /* 修复4: 响应式操作栏 */ .action-bar { display: flex; justify-content: flex-end; align-items: center; margin-top: 20px; gap: 30px; } .summary { font-weight: bold; font-size: 16px; } .summary span:last-child { color: #e6a23c; margin-left: 10px; } </style> ``` ### 问题原因解释 1. **重复列问题** - 原因:同时存在`产品单价`和`单价`两个相同含义的列 - 解决:移除冗余列,保持界面简洁 2. **用户硬编码问题** - 原因:`user = "aaa"`静态赋值无法适应实际用户场景 - 解决:使用响应式变量+动态获取逻辑,预留用户系统集成点 3. **库存更新问题** - 原因:加入购物车后直接刷新整个数据列表,导致: - 用户输入状态丢失 - 不必要的网络请求 - 界面闪烁 - 解决:添加`updateLocalStock`方法局部更新数据 4. **布局问题** - 原因:使用`float`布局导致: - 响应式适配困难 - 元素重叠风险 - 移动端显示异常 - 解决:改用Flex布局并添加间距控制 5. **数据一致性优化** - 金额计算:添加`.toFixed(2)`确保金额格式 - 类型转换:明确`Number()`转换防止字符串拼接 - 批量操作:使用`Promise.all`处理并行请求 6. **用户体验增强** - 添加操作过滤:跳过数量为0的商品 - 错误处理:细化错误提示信息 - 库存联动:购买后自动调整输入框最大值
阅读全文

相关推荐

<template> <el-input v-model="name" placeholder="请输入菜单名称" style="width: 200px" prefix-icon="el-icon-user"></el-input> <el-button class="el-icon-search" style="margin-left: 10px" type="primary" @click="load">查询</el-button> <el-button class="el-icon-refresh" style="margin-left: 10px" type="warning" @click="reset">重置</el-button> <el-button class="el-icon-plus" style="margin-right: 10px" type="success" @click="save(null)">新增</el-button> <el-button class="el-icon-close" style="margin-left: 10px" type="danger" @click="deleteByids" >批量删除</el-button> <el-table :data="tableData" border stripe :header-cell-style="getRowClass" @selection-change="handleSelectionChange" row-key="id" border default-expand-all> <el-table-column type="selection" width="55"></el-table-column> <el-table-column prop="id" label="id"></el-table-column> <el-table-column prop="name" label="菜单名称"></el-table-column> <el-table-column prop="path" label="菜单路径"></el-table-column> <el-table-column prop="icon" label="菜单图标"> <template v-slot:default="scope"> </template> </el-table-column> <el-table-column prop="pagePath" label="页面路径"></el-table-column> <el-table-column prop="description" label="菜单描述"></el-table-column> <el-table-column prop="sortNum" label="排序"></el-table-column> <el-table-column label="操作" width="300"> <template v-slot="scope"> <el-button type="success" size="mini" class="compact-btn" @click="save(scope.row.id)" v-if="!scope.row.pid && !scope.row.path">新增子菜单</el-button> <el-button type="prima

<template> <el-input placeholder="请输入标题查询" style="width: 200px" v-model="name"></el-input> <el-button type="info" plain style="margin-left: 10px" @click="load(1)">查询</el-button> <el-button type="warning" plain style="margin-left: 10px" @click="reset">重置</el-button> <el-button type="primary" plain @click="handleAdd">考试安排</el-button> <el-button type="danger" plain @click="delBatch">批量删除</el-button> <el-table :data="tableData" stripe @selection-change="handleSelectionChange"> <el-table-column type="selection" width="55" align="center"></el-table-column> <el-table-column prop="id" label="序号" width="80" align="center" sortable></el-table-column> <el-table-column prop="courseName" label="考试课程" show-overflow-tooltip></el-table-column> <el-table-column prop="teacherName" label="监考老师" show-overflow-tooltip></el-table-column> <el-table-column prop="roomName" label="考试教室" show-overflow-tooltip></el-table-column> <el-table-column prop="examTime" label="考试时间" show-overflow-tooltip></el-table-column> <el-table-column prop="time" label="创建时间"></el-table-column> <el-table-column label="操作" width="180" align="center"> <template v-slot="scope"> <el-button plain type="primary" @click="handleEdit(scope.row)" size="mini">编辑</el-button> <el-button plain type="danger" size="mini" @click=del(scope.row.id)>删除</el-button> </template> </el-table-column> </el-table> <el-pagination background @current-change="handleCurrentChange" :current-page="pageNum" :page-sizes="[5, 10, 20]" :page-size="pageSize" layout="total, prev, pager, next" :total="total"> </el-pagination>

<template> <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="150px"> <el-form-item label="采集数据提交的时间"> <el-date-picker v-model="daterangeTime" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" ></el-date-picker> </el-form-item> <el-form-item label="采集数据提交的地点" prop="position"> <el-input v-model="queryParams.position" placeholder="请输入采集数据提交的地点" clearable @keyup.enter.native="handleQuery" /> </el-form-item> <el-form-item label="采集人员编号" prop="userid"> <el-input v-model="queryParams.userid" placeholder="请输入采集人员编号" clearable @keyup.enter.native="handleQuery" /> </el-form-item> <el-form-item label="施工单位" prop="sgdw"> <el-input v-model="queryParams.sgdw" placeholder="请输入施工单位" clearable @keyup.enter.native="handleQuery" /> </el-form-item> <el-form-item label="监理单位" prop="jldw"> <el-input v-model="queryParams.jldw" placeholder="请输入监理单位" clearable @keyup.enter.native="handleQuery" /> </el-form-item> <el-form-item label="合同号" prop="hth"> <el-input v-model="queryParams.hth" placeholder="请输入合同号" clearable @keyup.enter.native="handleQuery" /> </el-form-item> <el-form-item label="编号" prop="bh"> <el-input v-model="queryParams.bh" placeholder="请输入编号" clearable @keyup.enter.native="handleQuery" /> </el-form-item> <el-form-item label="工程名称" prop="gcmc"> <el-input v-model="queryParams.gcmc" placeholder="请输入工程名称" clearable @keyup.enter.native="handleQuery" /> </el-form-item> <el-form-item label="施工时间"> <el-date-picker v-model="daterangeSgsj" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" ></el-date-picker> </el-form-item> <el-form-item> <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> </el-form-item> </el-form> <el-row :gutter="10" class="mb8"> <el-col :span="1.5"> <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['gjstjgjlb:sj32:add']" >新增</el-button> </el-col> <el-col :span="1.5"> <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['gjstjgjlb:sj32:edit']" >修改</el-button> </el-col> <el-col :span="1.5"> <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['gjstjgjlb:sj32:remove']" >删除</el-button> </el-col> <el-col :span="1.5"> <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['gjstjgjlb:sj32:export']" >导出</el-button> </el-col> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> </el-row> <el-table v-loading="loading" :data="sj32List" @selection-change="handleSelectionChange"> <el-table-column type="selection" width="55" align="center" /> <el-table-column label="ID" align="center" prop="id" /> <el-table-column label="采集数据提交的时间" align="center" prop="time" width="180"> <template slot-scope="scope"> {{ parseTime(scope.row.time, '{y}-{m}-{d}') }} </template> </el-table-column> <el-table-column label="采集数据提交的地点" align="center" prop="position" /> <el-table-column label="采集人员编号" align="center" prop="userid" /> <el-table-column label="施工单位" align="center" prop="sgdw" /> <el-table-column label="监理单位" align="center" prop="jldw" /> <el-table-column label="合同号" align="center" prop="hth" /> <el-table-column label="编号" align="center" prop="bh" /> <el-table-column label="工程名称" align="center" prop="gcmc" /> <el-table-column label="施工时间" align="center" prop="sgsj" width="180"> <template slot-scope="scope"> {{ parseTime(scope.row.sgsj, '{y}-{m}-{d}') }} </template> </el-table-column> <el-table-column label="工程部位-桩号" align="center" prop="gcbwZh" /> <el-table-column label="工程部位-墩台号" align="center" prop="gcbwDth" /> <el-table-column label="工程部位-孔号" align="center" prop="gcbwKh" /> <el-table-column label="钢筋规格" align="center" prop="gjgg" /> <el-table-column label="抽检数量" align="center" prop="cjsl" /> <el-table-column label="代表数量" align="center" prop="dbsl" /> <el-table-column label="生产日期" align="center" prop="scrq" width="180"> <template slot-scope="scope"> {{ parseTime(scope.row.scrq, '{y}-{m}-{d}') }} </template> </el-table-column> <el-table-column label="施工员" align="center" prop="sgy" /> <el-table-column label="专业工程师" align="center" prop="zygcs" /> <el-table-column label="检验结论" align="center" prop="jyjl" /> <el-table-column label="不合格处理" align="center" prop="bhgcl" /> <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <template slot-scope="scope"> <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['gjstjgjlb:sj32:edit']" >修改</el-button> <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['gjstjgjlb:sj32:remove']" >删除</el-button> <el-button size="mini" type="text" icon="el-icon-edit" @click="handleMyExport(scope.row)" >导出</el-button> </template> </el-table-column> </el-table> 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" /> <el-dialog :title="title" :visible.sync="open" width="900px" append-to-body> <template slot="title"> 钢筋丝头加工记录表 </template> <el-form ref="form" :model="form" :rules="rules" label-width="0"> 施工单位: <el-input v-model="form.sgdw" placeholder="请输入施工单位"></el-input> 合同号: <el-input v-model="form.hth" placeholder="请输入合同号"></el-input> 监理单位: <el-input v-model="form.jldw" placeholder="请输入监理单位"></el-input> 编号: <el-input v-model="form.bh" placeholder="请输入编号"></el-input> 工程名称: <el-input v-model="form.gcmc" placeholder="请输入工程名称"></el-input> 施工时间: <el-date-picker v-model="form.sgsj" type="date" placeholder="选择施工时间" style="width: 100%;"></el-date-picker> 工程部位(桩号、墩台号、孔号): <el-input v-model="form.gcbwZh" placeholder="桩号" style="width: 120px;"></el-input> - <el-input v-model="form.gcbwDth" placeholder="墩台号" style="width: 120px;"></el-input> - <el-input v-model="form.gcbwKh" placeholder="孔号" style="width: 120px;"></el-input> 钢筋规格: <el-input v-model="form.gjgg" placeholder="请输入钢筋规格"></el-input> 抽检数量(根): <el-input-number v-model="form.cjsl" :placeholder="form.cjsl ? '' : '数量'" style="width: 100%;"></el-input-number> 生产日期: <el-date-picker v-model="form.scrq" type="date" placeholder="选择生产日期" style="width: 100%;"></el-date-picker> 代表数量(根): <el-input-number v-model="form.dbsl" :placeholder="form.dbsl ? '' : '数量'" style="width: 100%;"></el-input-number> 施工实际情况 <el-table :data="sgsjqkList" :row-class-name="rowSgsjqkIndex" @selection-change="handleSgsjqkSelectionChange" ref="sgsjqk" style="width: 100%"> <el-table-column type="selection" width="50" align="center" /> <el-table-column label="序号" align="center" prop="index" width="90"/> <el-table-column prop="gjzj" label="钢筋直径" width="130" align="center"> <template slot-scope="scope"> <el-input v-model="scope.row.gjzj" size="small" placeholder="直径(mm)"></el-input> </template> </el-table-column> <el-table-column label="丝头螺纹检验" align="center"> <el-table-column prop="htg" label="环通规" width="110" align="center"> <template slot-scope="scope"> <el-select v-model="scope.row.htg" size="small" placeholder="√/×" style="width: 60px;"> <el-option label="√" value="√"></el-option> <el-option label="×" value="×"></el-option> </el-select> </template> </el-table-column> <el-table-column prop="hzg" label="环止规" width="110" align="center"> <template slot-scope="scope"> <el-select v-model="scope.row.hzg" size="small" placeholder="√/×" style="width: 60px;"> <el-option label="√" value="√"></el-option> <el-option label="×" value="×"></el-option> </el-select> </template> </el-table-column> </el-table-column> <el-table-column label="丝头外观检验" align="center"> <el-table-column prop="yxlwcd" label="有效螺纹长度" width="120" align="center"> <template slot-scope="scope"> <el-select v-model="scope.row.yxlwcd" size="small" placeholder="√/×" style="width: 60px;"> <el-option label="√" value="√"></el-option> <el-option label="×" value="×"></el-option> </el-select> </template> </el-table-column> <el-table-column prop="bwzlw" label="不完整螺纹" width="120" align="center"> <template slot-scope="scope"> <el-select v-model="scope.row.bwzlw" size="small" placeholder="√/×" style="width: 60px;"> <el-option label="√" value="√"></el-option> <el-option label="×" value="×"></el-option> </el-select> </template> </el-table-column> <el-table-column prop="wgjc" label="外观检查" width="150" align="center"> <template slot-scope="scope"> <el-input v-model="scope.row.wgjc" size="small" placeholder="外观情况"></el-input> </template> </el-table-column> </el-table-column> </el-table> 检验结论: <el-input v-model="form.jyjl" placeholder="检验结论"></el-input> 不合格处理: <el-input v-model="form.bhgcl" placeholder="不合格处理"></el-input> <el-col :span="1.5"> <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddSgsjqk">添加</el-button> </el-col> <el-col :span="1.5"> <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteSgsjqk">删除</el-button> </el-col> 施工员: <el-input v-model="form.sgy" placeholder="姓名" style="width: 120px; margin-right: 40px;"></el-input> 专业工程师: <el-input v-model="form.zygcs" placeholder="姓名" style="width: 120px;"></el-input> </el-form> <el-button type="primary" @click="submitForm">确 定</el-button> <el-button @click="cancel">取 消</el-button> </el-dialog> </template> <script> import { listSj32, getSj32, delSj32, addSj32, updateSj32, exportMyExcel } from "@/api/gjstjgjlb/sj32" export default { name: "Sj32", dicts: ['sys_dui_nodui'], data() { return { // 遮罩层 loading: true, // 选中数组 ids: [], // 子表选中数据 checkedSgsjqk: [], // 非单个禁用 single: true, // 非多个禁用 multiple: true, // 显示搜索条件 showSearch: true, // 总条数 total: 0, // 钢筋丝头加工记录表表格数据 sj32List: [], // 施工实际情况表格数据 sgsjqkList: [], // 弹出层标题 title: "", // 是否显示弹出层 open: false, // 外键时间范围 daterangeTime: [], // 外键时间范围 daterangeSgsj: [], // 查询参数 queryParams: { pageNum: 1, pageSize: 10, time: null, position: null, userid: null, sgdw: null, jldw: null, hth: null, bh: null, gcmc: null, sgsj: null, }, // 表单参数 form: {}, // 表单校验 rules: { } } }, created() { this.getList() }, methods: { /** 查询钢筋丝头加工记录表列表 */ getList() { this.loading = true this.queryParams.params = {} if (null != this.daterangeTime && '' != this.daterangeTime) { this.queryParams.params["beginTime"] = this.daterangeTime[0] this.queryParams.params["endTime"] = this.daterangeTime[1] } if (null != this.daterangeSgsj && '' != this.daterangeSgsj) { this.queryParams.params["beginSgsj"] = this.daterangeSgsj[0] this.queryParams.params["endSgsj"] = this.daterangeSgsj[1] } listSj32(this.queryParams).then(response => { this.sj32List = response.rows this.total = response.total this.loading = false }) }, // 取消按钮 cancel() { this.open = false this.reset() }, // 表单重置 reset() { this.form = { id: null, time: null, position: null, userid: null, sgdw: null, jldw: null, hth: null, bh: null, gcmc: null, sgsj: null, gcbwZh: null, gcbwDth: null, gcbwKh: null, gjgg: null, cjsl: null, dbsl: null, scrq: null, sgy: null, zygcs: null, jyjl: null, bhgcl: null } this.sgsjqkList = [] this.resetForm("form") }, /** 搜索按钮操作 */ handleQuery() { this.queryParams.pageNum = 1 this.getList() }, /** 重置按钮操作 */ resetQuery() { this.daterangeTime = [] this.daterangeSgsj = [] this.resetForm("queryForm") this.handleQuery() }, // 多选框选中数据 handleSelectionChange(selection) { this.ids = selection.map(item => item.id) this.single = selection.length!==1 this.multiple = !selection.length }, /** 新增按钮操作 */ handleAdd() { this.reset() this.open = true this.title = "添加钢筋丝头加工记录表" }, /** 修改按钮操作 */ handleUpdate(row) { this.reset() const id = row.id || this.ids getSj32(id).then(response => { this.form = response.data this.sgsjqkList = response.data.sgsjqkList this.open = true this.title = "修改钢筋丝头加工记录表" }) }, /** 提交按钮 */ submitForm() { this.$refs["form"].validate(valid => { if (valid) { this.form.sgsjqkList = this.sgsjqkList if (this.form.id != null) { updateSj32(this.form).then(response => { this.$modal.msgSuccess("修改成功") this.open = false this.getList() }) } else { addSj32(this.form).then(response => { this.$modal.msgSuccess("新增成功") this.open = false this.getList() }) } } }) }, /** 删除按钮操作 */ handleDelete(row) { const ids = row.id || this.ids this.$modal.confirm('是否确认删除钢筋丝头加工记录表编号为"' + ids + '"的数据项?').then(function() { return delSj32(ids) }).then(() => { this.getList() this.$modal.msgSuccess("删除成功") }).catch(() => {}) }, /** 施工实际情况序号 */ rowSgsjqkIndex({ row, rowIndex }) { row.index = rowIndex + 1 }, /** 施工实际情况添加按钮操作 */ handleAddSgsjqk() { let obj = {} obj.gjzj = "" obj.htg = "" obj.hzg = "" obj.yxlwcd = "" obj.bwzlw = "" obj.wgjc = "" this.sgsjqkList.push(obj) }, /** 施工实际情况删除按钮操作 */ handleDeleteSgsjqk() { if (this.checkedSgsjqk.length == 0) { this.$modal.msgError("请先选择要删除的施工实际情况数据") } else { const sgsjqkList = this.sgsjqkList const checkedSgsjqk = this.checkedSgsjqk this.sgsjqkList = sgsjqkList.filter(function(item) { return checkedSgsjqk.indexOf(item.index) == -1 }) } }, /** 复选框选中数据 */ handleSgsjqkSelectionChange(selection) { this.checkedSgsjqk = selection.map(item => item.index) }, /** 导出按钮操作 */ handleExport() { this.download('gjstjgjlb/sj32/export', { ...this.queryParams }, sj32_${new Date().getTime()}.xlsx) }, handleMyExport(row) { const id = row.id exportMyExcel(id).then(response => { this.$modal.msgSuccess("导出成功"); }); } } } </script> 分析以上代码

<template> 部门管理 <el-button type="primary" @click="fetchData" ><el-icon><Search /></el-icon> 搜索</el-button > <el-button type="success" @click="showAddDialog" ><el-icon></el-icon>新增</el-button > <el-button type="danger" @click="batchDelete" ><el-icon><delete /></el-icon>批量删除</el-button >

<el-table :data="tableData" border stripe @selection-change="handleSelectionChange"> <el-table-column type="selection" width="45" align="center" /> <el-table-column prop="id" label="ID" width="70" align="center" /> <el-table-column prop="name" label="姓名" min-width="100" /> <el-table-column label="头像" width="90" align="center" /> <el-table-column prop="gender" label="性别" width="80" align="center" /> <el-table-column prop="job" label="职位" min-width="120" /> <el-table-column prop="entrydate" label="入职时间" width="110" align="center" /> <el-table-column prop="createTime" label="创建时间" min-width="160" align="center" /> <el-table-column prop="updateTime" label="最后修改" min-width="160" align="center" /> <el-table-column label="操作" width="150" align="center" fixed="right"> <template #default="{ row }"> <el-button size="small" type="primary" icon="el-icon-edit" @click="handleEdit(row)" >编辑</el-button > <el-button size="small" type="danger" icon="el-icon-delete" @click="handleDelete(row.id)" >删除</el-button > </template> </el-table-column> </el-table> </template> 帮我根据前端所需要的数据生成mock云端假数据的json格式

<template> <el-dialog :title="dialogMode === 'create' ? '新建' : dialogMode === 'edit' ? '修改' : '查看'" :visible.sync="dialogVisible" :modal-append-to-body="true" append-to-body :close-on-click-modal="false" class="fixed-dialog" width="60%"> <el-form label-width="80px"> <el-row :gutter="10"> <el-col :span="6"> <el-form-item size="mini" label="项目名称"> <el-input v-model="projectName" clearable style="width:100%" size="mini"></el-input> </el-form-item> </el-col> <el-col :span="6"> <el-form-item size="mini" label="项目编号"> <el-input v-model="projectCode" clearable style="width:100%" size="mini"></el-input> </el-form-item> </el-col> <el-col :span="12"> <el-form-item size="mini" label="项目周期"> <el-date-picker v-model="value1" range-separator="→" start-placeholder="请选择开始日期" end-placeholder="请选择结束日期" type="daterange" size="mini" style="width: 100%;"> </el-date-picker> </el-form-item> </el-col> </el-row> <el-row> <el-col :span="6"> <el-form-item label="负责人" size="mini" style="width: fit-content;"> <el-input v-model="projectManager" clearable style="width:100%" size="mini"></el-input> </el-form-item> </el-col> </el-row> <el-row> <el-col :span="24"> <el-form-item label="项目概述"> <el-input v-model="projectDescription" :rows="2"></el-input> </el-form-item> </el-col> </el-row> <el-container style="height: 100%;"> <el-header> <el-row :gutter="10" type="flex"> <el-col :span="5"><el-select v-model="MaintenanceUnit" placeholder="请选择管养单位" size="mini" clearable> <el-option v-for="item in MaintenanceUnitoptions" :key="item.value" :label="item.label" :value="item.value"></el-option> </el-select> </el-col> <el-col :span="5"><el-select v-model="routeCode" placeholder="请选择路线编号" size="mini" clearable> <el-option v-for="item in routeCodeOptions" :key="item.value" :label="item.label" :value="item.value"></el-option></el-select></el-col> <el-col :span="5"><el-input v-model="formSearch" placeholder="请输入边坡编号或名称" size="mini" clearable> </el-input></el-col> <el-col :span="5"><el-select v-model="evaluateLevel" placeholder="请选择技术状态等级" size="mini" clearable> <el-option v-for="item in evaluateLeveloptions" :key="item.value" :label="item.label" :value="item.value" filterable></el-option></el-select></el-col> <el-col :span="2" :offset="2"><el-button type="primary" size="mini" style="width:100%" icon="el-icon-search" @click="searchForm">搜索</el-button></el-col> </el-row> </el-header> <el-main> <el-table style="width: 100%; overflow-y: auto;" border :data='formTabledata' :header-row-style="{ height: '40px' }" :header-cell-style="{ padding: '0', height: '40px', lineHeight: '40px', textAlign: 'center' }" class="scrollable-table" :cell-style="{ textAlign: 'center' }" @selection-change="handleSelectionChange"> <el-table-column type="selection"></el-table-column> <el-table-column label="管养单位" prop="maintenanceCompanyName" width="290"></el-table-column> <el-table-column label="路线编号" prop="routeCode" width="100"></el-table-column> <el-table-column label="边坡编号" prop="sideSlopeCode" width="240"></el-table-column> <el-table-column label="边坡名称" prop="sideSlopeName" width="267"></el-table-column> <el-table-column label="技术状态等级" width="110"> <template slot-scope="scope"> {{ mapEvaluateLevel(scope.row.evaluateLevel) }} </template></el-table-column> </el-table> </el-main> <el-footer> <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" layout="total, prev, pager, next" :current-page="pageParams.pageNo" :total="total"> </el-pagination> </el-footer> </el-container> </el-form> <el-button @click="dialogVisible = false">取消</el-button> <el-button type="primary">提交</el-button> </el-dialog> <el-container style="height: 100%;"> <el-header> <el-row :gutter="10" type="flex"> <el-col :span="11"> <el-col :span="6"><el-input v-model="Ceshibianhao" placeholder="项目名称" size="mini"></el-input></el-col> <el-col :span="6"><el-select v-model="selectStatus" placeholder="项目状态" size="mini" clearable> <el-option v-for="item in StatusOptions" :key="item.value" :label="item.label" :value="item.value" filterable></el-option> </el-select></el-col> <el-col :span="11"><el-date-picker v-model="value1" range-separator="→" start-placeholder="请选择开始日期" end-placeholder="请选择结束日期" type="daterange" size="mini" style="width: 100%;"> </el-date-picker> </el-col> <el-col :span="1"><el-button type="primary" size="mini">查询</el-button></el-col> </el-col> <el-col :span="1" :offset="1"><el-button type="success" size="mini" style="width:100%" @click="openCreateDialog">新建</el-button></el-col> </el-row> </el-header> <el-main> <el-table :data="tableData" border style="width: 100%;" :main-height="400" :header-row-style="() => { return 'line-height:15px'; }" :cell-style="{ textAlign: 'center' }" :header-cell-style="{ textAlign: 'center' }"> <el-table-column label="序号" type="index" width="120"></el-table-column> <el-table-column label="项目名称" width="250"></el-table-column> <el-table-column label="项目编号" width="150"></el-table-column> <el-table-column label="项目周期" width="250"></el-table-column> <el-table-column label="项目状态" width="200"></el-table-column> <el-table-column label="边坡总数" width="150"></el-table-column> <el-table-column label="已完成边坡数" width="194"></el-table-column> <el-table-column label="完成率" width="150"></el-table-column> <el-table-column label="操作" width="200"> <template slot-scope="scope"> <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button> <el-button type="text" size="small">编辑</el-button> <el-button type="text" size="small">删除</el-button> </template> </el-table-column> </el-table> </el-main> <el-footer> <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" layout="total,prev, sizes, pager, next,jumper" :current-page.sync="pageParams.pageNo" :page-size="pageParams.pageSize" :page-sizes="[10, 40, 60, 100]" :total="pageParams.total"> </el-pagination> </el-footer> </el-container> </template> <script> import { mapCfg } from "@/utils"; import { getPeriodicInspectionPageList, addPeriodicInspection, modifyPeriodicInspection, deletePeriodicInspection, getPeriodicInspectionSideSlopePageList, completePeriodicInspection } from '../../api/testProject'; export default { name: "testProjeck", maxins: [], data() { return { Ceshibianhao: '', xiangmuzhuangtai: '', value1: '', total: 0, pageParams: { pageNo: 1, pageSize: 10, }, dialogpageParams: { pageNo: 1, pageSize: 20 }, StatusOptions: [], selectStatus: [], tableData: [], MaintenanceUnitoptions: [], routeCodeOptions: [], checkList: {}, dialogMode: "create", dialogVisible: false, projectName: '',//项目名称 projectCode: '',//项目编码 projectManager: '',//项目负责人 projectDescription: '',//项目概述 formLevellist: '', formTabledata: [], orgId: '', routeCode: '',//路线 evaluateLeveloptions: [],//技术等级状态 evaluateLevel: '', formSearch: '',////搜索数据 filterForm: { MaintenanceUnit: '', routeCode: '' }, MaintenanceUnit: {},//管养单位 Unitoptions: { value: "value", label: "label", children: "children" } } }, async created() { await this.getEvaluateLevel() this.LoadListData(); this.getStatus(); this.loadTableData(); }, methods: { handleSelectionChange(val) { console.log(val) }, searchForm() { this.filterForm = { maintenanceCompanyName: this.MaintenanceUnit, routeCode: this.routeCode, searchKey: this.sideSlopeCode, }; this.pageParams.pageNo = 1; this.LoadListData(); }, // 映射技术状态等级 mapEvaluateLevel(level) { const option = this.evaluateLeveloptions.find(item => item.value === level); return option ? option.label : level; }, async LoadListData() { const params = { orgId: '', routeCode: this.filterForm.routeCode, evaluateLevel: '', SearchKey: '', sideSlopeName: '', pageSize: this.pageParams.pageSize, pageNo: this.pageParams.pageNo, maintenanceCompanyName: this.filterForm.maintenanceCompanyName } const res = await getPeriodicInspectionSideSlopePageList(params); // 处理管养单位选项(去重) const maintenanceCompanies = res.entities.map(item => ({ value: item.maintenanceCompanyId, label: item.maintenanceCompanyName })); // 使用reduce去重 this.MaintenanceUnitoptions = maintenanceCompanies.reduce((acc, current) => { const exists = acc.some(item => item.value === current.value); if (!exists) { acc.push(current); } return acc; }, []); // 处理路线编号选项(去重) const routeCodes = res.entities.map(item => item.routeCode); this.routeCodeOptions = [...new Set(routeCodes)].map(code => ({ value: code, label: code })); this.formTabledata = res.entities.map(item => { return { ...item, } }); this.total = res.entityCount; }, /**分页 */ handleSizeChange(val) { this.pageParams.pageNo = 1; this.pageParams.pageSize = val; this.LoadListData() }, handleCurrentChange(val) { this.pageParams.pageNo = val; this.LoadListData() }, //评定等级 async getEvaluateLevel() { const levelList = await mapCfg('Inspection.Regular.RegularEvaluateLevel')(); this.evaluateLeveloptions = levelList.map(item => ({ value: item.key, label: item.value, })) }, //项目状态字典 async getStatus() { try { const dictList = await mapCfg("Inspection.Periodic.PeriodicInspectionStatus")(); this.StatusOptions = dictList.map(item => ({ value: item.key, label: item.value })); } catch (error) { console.error('获取失败', error); } }, openCreateDialog() { this.dialogMode = 'create'; this.dialogVisible = true; }, async loadTableData() { const periodicId = '' const res = await getPeriodicInspectionPageList({ periodicId }); console.log(res) } }, } </script> <style lang="scss" scoped> .el-header { color: #333; text-align: center; line-height: 60px; } .el-main { color: #333; text-align: center; line-height: 100%; padding-left: 5px; padding-top: 0px; } .formBorder { position: relative; /* 添加相对定位 */ border: thin dotted black; padding: 10px; /* 添加上边框文字效果 */ &::before { content: "项目信息"; /* 要显示的文字 */ position: absolute; top: -10px; /* 向上移动一半高度 */ left: 40px; /* 距离左边距 */ background-color: #fff; /* 背景色与页面一致 */ padding: 0 10px; font-size: 14px; color: #606266; } } .formBorder2 { margin-top: 15px; position: relative; /* 添加相对定位 */ border: thin dotted black; padding: 10px; /* 添加上边框文字效果 */ &::before { content: "待检边坡"; /* 要显示的文字 */ position: absolute; top: -10px; /* 向上移动一半高度 */ left: 40px; /* 距离左边距 */ background-color: #fff; /* 背景色与页面一致 */ padding: 0 10px; font-size: 14px; color: #606266; } .el-main { display: flex; } } .dialog-footer { padding: 10px 20px; border-top: 1px solid #ebeef5; text-align: center; } .formBorder2::v-deep .el-main { display: flex; overflow-y: auto; height: 100% !important; } </style> 为什么表格中的选择桥梁和管养单位只显示当前页面的单位

<el-dialog :title="detailTitle" v-model="openDetail" style="width: 1400px; height: 800px" append-to-body > <el-form ref="powerRef" :model="main" :rules="rules" label-width="80px"> <el-row> <el-col :span="8"> <el-form-item label="年月" prop="years" label-width="140"> <el-date-picker clearable v-model="main.years" type="month" format="YYYY/MM" value-format="YYYY/MM" placeholder="Please select" :readonly="main.reviewStatus != '4'" /> </el-form-item> </el-col> <el-col :span="8"> <el-form-item label="绿电溢价" prop="premium" label-width="140"> <el-input v-model="main.premium" placeholder="Please input" :readonly="main.reviewStatus != '4'" /> </el-form-item> </el-col> <el-col :span="8"> <el-form-item label="厂别" prop="fact" label-width="140"> <el-input v-model="main.fact" placeholder="Please input" readonly /> </el-form-item> </el-col> </el-row> <el-row> <el-col :span="12"> <el-form-item label="启动人" prop="nickName" label-width="140"> <el-input v-model="main.nickName" placeholder="Please input" readonly /> </el-form-item> </el-col> <el-col :span="12"> <el-form-item label="审核状态" prop="reviewStatus" label-width="140" > <dict-tag :options="rsc_review_status" :value="main.reviewStatus" /> </el-form-item> </el-col> </el-row> </el-form> <el-row :gutter="10" class="mb8"> <el-col :span="1.5"> <el-button type="primary" plain icon="Plus" @click="handleAddDetail" v-hasPermi="['rsc:power:add']" >新增</el-button > </el-col> <el-col :span="1.5"> <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDeleteDetail" v-hasPermi="['rsc:power:remove']" >删除</el-button > </el-col> <el-col :span="1.5"> <el-button type="warning" plain icon="Upload" @click="handleImport" v-hasPermi="['rsc:power:import']" >导入</el-button > </el-col> <el-col :span="1.5"> <el-button type="warning" plain icon="Upload" @click="handleImportAnnex" v-hasPermi="['rsc:power:import']" >附件</el-button > </el-col> <el-col :span="1.5"> <el-button type="warning" plain icon="View" @click="handleView" v-hasPermi="['rsc:power:import']" >预览附件</el-button > </el-col> <el-col :span="1.5"> <el-button type="warning" plain icon="View" @click="handleDeleteFile" v-hasPermi="['rsc:power:import']" >删除附件</el-button > </el-col> </el-row> <el-table v-loading="loading" :data="powerDataList" @selection-change="handleDetailSelectionChange" :summary-method="getSummeries" show-summary border > <el-table-column type="selection" width="55" align="center" /> <el-table-column label="區域" align="center" prop="locationName" width="120" > </el-table-column> <el-table-column label="动力用量(度)" align="center" prop="powerUsage" width="120" > </el-table-column> <el-table-column label="照明用量(度)" align="center" prop="lightingUsage" width="120" > </el-table-column> <el-table-column label="线路损耗(度)" align="center" prop="lineLoss" width="120" > </el-table-column> <el-table-column label="市電(度)" align="center" prop="electricity" width="100" > </el-table-column> <el-table-column label="綠電(度)" align="center" prop="greenElectricity" width="100" > </el-table-column> <el-table-column label="電網用电量合計(度)" align="center" prop="powerGridTotal" width="160" > </el-table-column> <el-table-column label="幣別" align="center" prop="currency"> <template #default="scope"> <dict-tag :options="rsc_currency_type" :value="scope.row.currency" /> </template> </el-table-column> <el-table-column label="单价(元/度)" align="center" prop="unitPrice" width="120" > </el-table-column> <el-table-column label="電網用电金額(元)" align="center" prop="electricityBills" width="150" > </el-table-column> <el-table-column label="光伏用電量(度)" align="center" prop="photovoltaicUsage" width="140" > </el-table-column> <el-table-column label="光伏用電單價(元/度)" align="center" prop="photovoltaicUnitPrice" width="160" > </el-table-column> <el-table-column label="光伏用電金額(元)" align="center" prop="photovoltaicBills" width="150" > </el-table-column> <el-table-column label="用電量合計" align="center" prop="electricityTotal" width="100" > </el-table-column> <el-table-column label="用電金額合計" align="center" prop="totalBills" width="120" > </el-table-column> <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="140" fixed="left" > <template #default="scope"> <el-tooltip content="修改" placement="top"> <el-button link type="primary" icon="Edit" @click="handleUpdateDetail(scope.row)" v-hasPermi="['rsc:power:edit']" ></el-button> </el-tooltip> </template> </el-table-column> </el-table> <template #footer> <el-button type="primary" @click="savePower" v-if="main.reviewStatus != '1'" >保存</el-button > <el-button type="primary" @click="startProcess" v-if="main.reviewStatus == '4'" >提交</el-button > <el-button type="primary" @click="cacelPower" v-if=" main.reviewStatus != 1 && main.reviewStatus != 4 && main.reviewStatus != null " >取消申请</el-button > <el-button @click="cancelDetail">取 消</el-button> </template> </el-dialog> 分析以上代码,帮我实现table表头与合计行的固定,不随表格列滚动

<template> <el-table :data="tableData" style="width: 100%" @selection-change="handleSelectionChange"> <el-table-column type="selection" width="55"/> <el-table-column label="产品名称" width="220"> <template #default="scope"> <el-link type="primary" :underline="false" @click="goToProductDetail(scope.row.id)"> {{ scope.row.name }} ※点击进入详细画面 </el-link> </template> </el-table-column> <el-table-column property="categoryName" label="产品分类"width="120"/> <el-table-column property="price" label="产品单价"width="120"/> <el-table-column property="createAt" label="生产日期"width="250"/> <el-table-column property="price" label="单价"width="120"/> <el-table-column property="stock" label="库存"width="120"/> <el-table-column label="购买数量" width="180"> <template #default="scope"> <el-input-number v-model="scope.row.number" :min="0" :max="scope.row.stock" size="small" controls-position="right"/> </template> </el-table-column> <el-table-column label="合计" width="120"> <template #default="scope"> {{ scope.row.price * scope.row.number }} </template> </el-table-column> <el-table-column label="操作" width="180"> <template #default="scope"> <el-button size="small" @click="handleEdit(scope.$index,scope.row)"> 编辑 </el-button> <el-button size="small" type="danger" @click="handleDelete(scope.$index,scope.row)"> 删除 </el-button> </template> </el-table-column> </el-table> 总金额: {{ allAmount }} </template> <script setup> import productApi from '@/api/products' import { ref, computed } from 'vue'; const tableData = ref([]); const router = useRouter(); const user = "aaa" const allcheckbox = ref([]) const goToProductDetail = (productId) => { router.push(/home/test${productId}) } const handleEdit = (index, row) => { console.log(index, row) } // 实际删除操作 const handleDelete = (index, row) => { tableData.value.splice(index, 1); }; function handleSelectionChange(selection) { allcheckbox.value = selection } // 获取商品数据 function getProduct() { productApi.getAll(user).then(res => { tableData.value = res.data.map(item => ({ ...item, number: item.number || 0, })); }); } const allAmount = computed(()=>{ let totle = 0 allcheckbox.value.forEach(item=>{ if(item.sum){ totle+=item.sum } }) return totle }) onMounted(() => { getProduct(); }); </script> <style> .summary { float: right; margin-top: 50px; margin-right: 500px; } </style> 总金额加算为什么不好使

最新推荐

recommend-type

基于Java医院药品管理系统论文

基于Java医院药品管理系统论文
recommend-type

Kafka消息队列架构及高可用配置实战.doc

Kafka消息队列架构及高可用配置实战.doc
recommend-type

springboot基于Java的宠物用品系统的设计与实现.doc

springboot基于Java的宠物用品系统的设计与实现
recommend-type

接口逻辑电平标准.pptx

电路设计+接口逻辑电路+各种接口电平+学习和交流
recommend-type

JAVA某店POS积分管理系统(源代码+论文)

java
recommend-type

Mockingbird v2:PocketMine-MP新防作弊机制详解

标题和描述中所涉及的知识点如下: 1. Mockingbird反作弊系统: Mockingbird是一个正在开发中的反作弊系统,专门针对PocketMine-MP服务器。PocketMine-MP是Minecraft Pocket Edition(Minecraft PE)的一个服务器软件,允许玩家在移动平台上共同游戏。随着游戏的普及,作弊问题也随之而来,因此Mockingbird的出现正是为了应对这种情况。 2. Mockingbird的版本迭代: 从描述中提到的“Mockingbird的v1变体”和“v2版本”的变化来看,Mockingbird正在经历持续的开发和改进过程。软件版本迭代是常见的开发实践,有助于修复已知问题,改善性能和用户体验,添加新功能等。 3. 服务器性能要求: 描述中强调了运行Mockingbird的服务器需要具备一定的性能,例如提及“WitherHosting的$ 1.25计划”,这暗示了反作弊系统对服务器资源的需求较高。这可能是因为反作弊机制需要频繁处理大量的数据和事件,以便及时检测和阻止作弊行为。 4. Waterdog问题: Waterdog是另一种Minecraft服务器软件,特别适合 PocketMine-MP。描述中提到如果将Mockingbird和Waterdog结合使用可能会遇到问题,这可能是因为两者在某些机制上的不兼容或Mockingbird对Waterdog的特定实现尚未完全优化。 5. GitHub使用及问题反馈: 作者鼓励用户通过GitHub问题跟踪系统来报告问题、旁路和功能建议。这是一个公共代码托管平台,广泛用于开源项目协作,便于开发者和用户进行沟通和问题管理。作者还提到请用户在GitHub上发布问题而不是在评论区留下不好的评论,这体现了良好的社区维护和用户交流的实践。 6. 软件标签: “pocketmine”和“anticheat”(反作弊)作为标签,说明Mockingbird是一个特别为PocketMine-MP平台开发的反作弊软件。而“PHP”则可能指的是Mockingbird的开发语言,虽然这个信息与常见的Java或C++等开发Minecraft相关软件的语言不同,但并不排除使用PHP进行服务器端开发的可能性,尤其是对于处理动态网页、服务器端脚本等场景。 7. 压缩包文件: “Mockingbird-stable”是一个文件名称,很可能表示这是一个包含最新稳定版Mockingbird反作弊系统的压缩包。通常,这样的文件名中包含“stable”意味着这是一个经过充分测试且推荐用于生产环境的版本。 8. 社区协作和用户参与: 特别感谢部分提到了shur,这可能是对某位贡献者或社区成员的感激之情。这种感谢表明了软件开发不仅是开发者个人的劳动成果,同时也依赖于社区的支持和参与,包括提供反馈、报告问题、贡献代码和文档等。 总结以上内容,我们可以看到Mockingbird作为一款反作弊系统,其开发和维护需要依赖于社区的广泛参与和支持,同时还需要强大的服务器后端作为支撑。通过不断迭代更新版本,开发者希望解决现有问题,提高反作弊效率,并希望与社区保持良好的沟通,以持续优化产品。
recommend-type

“历史人物独白解说”视频:数据处理的6种革命性技术

# 1. 数据处理的历史回顾与技术演进 数据处理的历史,从最初的简单机械记录,到如今复杂的数据处理体系,不仅反映了技术的演进,也映射了人类社会进步的轨迹。在计算机技术发展初期,数据处理主要依靠打孔卡片和磁带,通过批处理的方式进行,效率低下且出错率高。随着技术的发展,上世纪70年代,关系型数据库的出现大大提高了数据处理的效率和准确性,为数据处理技术的发展奠定了基础。 随后,随着互
recommend-type

怎么判断多级运放电路的稳定性?

<think>首先,用户的问题是关于判断多级运算放大器电路的稳定性。我需要根据系统级指令来构建回答。 系统级指令: - 所有行内数学表达式必须使用$...$格式。 - 独立公式必须使用$$...$$格式并单独成段。 - LaTeX语法正确。 - 使用中文回答。 - 生成相关问题。 - 在回答中引用的段落末尾自然地添加引用标识,例如[^1]。 用户可见层指令: - 回答结构清晰,帮助用户逐步解决问题。 - 尽量保证回答真实可靠。 参考引用: - 引用[1]:关于集成运算放大电路的设计、组成和性能评估。 - 引用[2]:高频电路中运放的带宽限制,一级放大电路的增益通常为100倍,过高会引起振
recommend-type

利用AHP和节点集中度解决影响力最大化问题的Flask应用教程

从给定的文件信息中,我们可以提取以下相关知识点进行详细说明: ### 标题知识点 **IM问题与AHP结合** IM问题(Influence Maximization)是网络分析中的一个核心问题,旨在识别影响网络中信息传播的关键节点。为了求解IM问题,研究者们常常结合使用不同的算法和策略,其中AHP(Analytic Hierarchy Process,分析层次结构过程)作为一种决策分析方法,被用于评估网络节点的重要性。AHP通过建立层次模型,对各个因素进行比较排序,从而量化影响度,并通过一致性检验保证决策结果的有效性。将AHP应用于IM问题,意味着将分析网络节点影响的多个维度,比如节点的中心性(centrality)和影响力。 **集中度措施** 集中度(Centralization)是衡量网络节点分布状况的指标,它反映了网络中节点之间的连接关系。在网络分析中,集中度常用于识别网络中的“枢纽”或“中心”节点。例如,通过计算网络的度中心度(degree centrality)可以了解节点与其他节点的直接连接数量;接近中心度(closeness centrality)衡量节点到网络中其他所有节点的平均距离;中介中心度(betweenness centrality)衡量节点在连接网络中其他节点对的最短路径上的出现频率。集中度高意味着节点在网络中处于重要位置,对信息的流动和控制具有较大影响力。 ### 描述知识点 **Flask框架** Flask是一个轻量级的Web应用框架,它使用Python编程语言开发。它非常适合快速开发小型Web应用,以及作为微服务架构的一部分。Flask的一个核心特点是“微”,意味着它提供了基本的Web开发功能,同时保持了框架的小巧和灵活。Flask内置了开发服务器,支持Werkzeug WSGI工具包和Jinja2模板引擎,提供了RESTful请求分发和请求钩子等功能。 **应用布局** 一个典型的Flask应用会包含以下几个关键部分: - `app/`:这是应用的核心目录,包含了路由设置、视图函数、模型和控制器等代码文件。 - `static/`:存放静态文件,比如CSS样式表、JavaScript文件和图片等,这些文件的内容不会改变。 - `templates/`:存放HTML模板文件,Flask将使用这些模板渲染最终的HTML页面。模板语言通常是Jinja2。 - `wsgi.py`:WSGI(Web Server Gateway Interface)是Python应用程序和Web服务器之间的一种标准接口。这个文件通常用于部署到生产服务器时,作为应用的入口点。 **部署到Heroku** Heroku是一个支持多种编程语言的云平台即服务(PaaS),它允许开发者轻松部署、运行和管理应用。部署Flask应用到Heroku,需要几个步骤:首先,创建一个Procfile文件,告知Heroku如何启动应用;其次,确保应用的依赖关系被正确管理,通常通过一个requirements.txt文件列出所有依赖;最后,使用Git将应用推送到Heroku提供的仓库,Heroku会自动识别Procfile并开始部署过程。 ### 标签知识点 **HTML** HTML(HyperText Markup Language,超文本标记语言)是用于创建网页和Web应用的标准标记语言。它定义了网页的结构和内容。HTML文件由一系列元素组成,这些元素通过标签(tags)来表示,如`<p>`代表段落,`<a>`代表链接,`<img>`代表图像等。HTML5是当前使用的最新版本,支持更多的特性,如离线存储、多媒体和图形等。 ### 压缩包子文件的文件名称列表知识点 **IMproblem-using-AHP-and-centralisation-of-nodes-master** 这里的文件名称“IMproblem-using-AHP-and-centralisation-of-nodes-master”表明了一个GitHub仓库的名称,其中包含了源代码以及与项目相关的所有文件。从名称中可以看出,该仓库是关于如何结合AHP和节点集中度分析来解决IM问题的Flask应用程序。文件名中的“master”表明这是仓库的主分支(现在叫做main分支),它是项目最新的、可部署的代码版本。 综合来看,本段信息为我们提供了构建和部署一个使用Flask框架、针对IM问题使用AHP和节点集中度分析的Web应用的方法和步骤。同时,介绍了应用在不同环节中所需技术和组件的详细知识点。
recommend-type

视频内容自动生成算法:突破性的8大最新进展

# 1. 视频内容自动生成算法概述 ## 算法发展背景 随着人工智能技术的迅速发展,视频内容自动生成算法已经成为媒体和娱乐行业的重要工具。这些算法能够自动编辑和合成视频内容,使内容创作者能够以较低的成本和时间生成高质量的视频。从社交媒体动态到在线教育内容,视频内容自动生成的应用场景正在不断扩大。 ## 核心技术简述 视