Commit bb26de2c authored by 祁正's avatar 祁正

制造工厂

parent 6cc6a034
......@@ -16,3 +16,11 @@ export function insertFactory(query) {
data: query,
})
}
// 编辑制造工厂
export function updateFactory(query) {
return request({
url: '/control/systemFactory/update',
method: 'post',
data: query,
})
}
<template>
<div style="padding: 30px">
<el-button type="primary" plain style="float: right;margin: 12px 0" @click="dialogVisible = true">新建</el-button>
<el-button type="primary" plain style="float: right;margin: 12px 0" @click="addFactory">新建</el-button>
<el-table :data="tableList" style="width: 100%;" border>
<el-table-column label="序号" align="center">
<template #default="scope">
......@@ -19,27 +19,26 @@
<el-table-column label="操作" align="center">
<template #default="scope">
<el-button type="text">编辑</el-button>
<el-button @click="update(scope.row)" type="text">编辑</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
v-show="total > 0"
v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getTableList"
/>
<!-- 新增对话框-->
<el-dialog
style="margin-top: 300px;width: 500px;height: auto"
v-model="dialogVisible"
fullscreen
title="新增"
:title="dialogTitle"
width="500"
>
<el-form label-position="top" ref="formRef" :model="form" label-width="auto" style="max-width: 600px;">
......@@ -67,7 +66,7 @@
<script setup>
import {
getList, insertFactory
getList, insertFactory,updateFactory
} from '@/api/system/factory'
import { ElMessage } from 'element-plus'
......@@ -75,6 +74,8 @@ const tableList = ref([])
const total = ref(0)
const dialogVisible = ref(false)
const formRef = ref(null); // 创建一个表单的引用
const dialogTitle = ref('新增')
const tempObj = ref({})
const form = ref({})
......@@ -89,14 +90,32 @@ const submitForm = () => {
// 通过 formRef 访问表单的方法
formRef.value.validate((valid) => {
if (valid) {
if(dialogTitle === '新增'){
insertFactory(form.value).then(res=>{
if(res.code === 200){
if(res.data === 1){
ElMessage.success("新增成功")
dialogVisible.value = false
form.value = {}
getTableList()
}else {
ElMessage.error("新增失败")
}
})
}else{
//编辑
updateFactory(form.value).then(res=>{
if(res.data === 1){
ElMessage.success("修改成功")
dialogVisible.value = false
form.value = {}
getTableList()
}else {
ElMessage.error("修改失败")
}
})
}
} else {
return false;
}
......@@ -108,6 +127,23 @@ function cancelDialog(){
form.value = {}
}
function addFactory(){
dialogVisible.value = true
dialogTitle.value = '新增'
}
function update(row){
console.log(row)
dialogTitle.value = '编辑'
//浅拷贝
form.value = {
id:row.id,
factoryName:row.factoryName,
remark:row.remark
}
dialogVisible.value = true
}
function getTableList(){
getList(queryParams.value).then((response) => {
console.log(response)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment