From ea10117a46fbbe7dd831c3816217493d0da01bf9 Mon Sep 17 00:00:00 2001 From: yangys <y_ys79@sina.com> Date: 星期六, 13 一月 2024 22:46:44 +0800 Subject: [PATCH] 设备类型1 --- src/api/Api.js | 12 ++++ src/container/deviceType/index.vue | 4 src/container/deviceType/Manage-add-update.vue | 136 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 150 insertions(+), 2 deletions(-) diff --git a/src/api/Api.js b/src/api/Api.js index b6eac8b..c1738cf 100644 --- a/src/api/Api.js +++ b/src/api/Api.js @@ -13,6 +13,9 @@ // 鍙拌处淇濆瓨 accountCreate: '/account/create', accountUpdate: '/account/update', + //璁惧绫诲瀷 + deviceTypeCreate: '/devicetype/create', + deviceTypeUpdate: '/devicetype/update', // 杞﹂棿 宸ユ涓嬪暒鏁版嵁 getWsl: '/machine/workshopList', getPcl: '/machine/protocolList' @@ -78,6 +81,15 @@ export function accountUpdate(params) { return sendRequest(HttpConstants.accountUpdate, params) } + +// 璁惧绫诲瀷淇濆瓨 +export function deviceTypeCreate(params) { + return sendRequest(HttpConstants.deviceTypeCreate, params) +} +export function deviceTypeUpdate(params) { + return sendRequest(HttpConstants.deviceTypeUpdate, params) +} + // export function getWsl(params) { return getData(HttpConstants.getWsl, params) diff --git a/src/container/deviceType/Manage-add-update.vue b/src/container/deviceType/Manage-add-update.vue new file mode 100644 index 0000000..7cc28e3 --- /dev/null +++ b/src/container/deviceType/Manage-add-update.vue @@ -0,0 +1,136 @@ +<template> + <div> + <el-dialog + :title="!dataForm.id ? '鏂板缓' : '缂栬緫'" + :close-on-click-modal="false" + width="80%" + :visible.sync="addVisible"> + <!-- 娣诲姞鍐呭--> + <el-form :model="dataForm" label-width="100px" ref="dataForm"> + <el-row :gutter="20"> + + <el-col :xs="24":sm="6":md="6":lg="6":xl="6"> + <el-form-item label="鍚嶇О" prop="name"> + <el-input v-model="dataForm.name" placeholder="鍚嶇О" clearable></el-input> + </el-form-item> + </el-col> + + </el-row> + + </el-form> + <!-- 鎸夐挳 --> + <span slot="footer" class="dialog-footer"> + <el-button size="mini" @click="cancel">鍙栨秷</el-button> + <el-button size="mini" type="primary" @click="dataFormSubmit()">淇濆瓨</el-button> + </span> + </el-dialog> + </div> +</template> + +<script> + import { deviceTypeUpdate,deviceTypeCreate } from '@/api/Api' + export default { + props: ['addVisible','row'], + data() { + return { + visible: false, + dataForm: { + id: 0, // title鏄剧ず鏂板杩樻槸淇敼 + name: '' + } + + } + }, + watch: { + addVisible: { + handler (val) { + if (val) { + this.init() + } + }, + immediate: true + } + }, + created () { + console.log('add create'); + this.init(this.row) + }, + methods: { + init(row) { + if (this.$refs['dataForm']) { + this.$refs['dataForm'].resetFields() + } + if (row !== undefined) { + this.dataForm.id = row.id + this.dataForm.name = row.name + + } else { + this.dataForm.id = '' + } + }, + /* 鏌ヨ浣跨敤閮ㄩ棬*/ + cancel () { + this.$emit('close') + }, + /* 鎻愪氦*/ + dataFormSubmit() { + if (this.dataForm.id === '') { // 鏂板 + deviceTypeCreate(this.dataForm).then(res => { + this.$message({ + message: '鏂板鎴愬姛', + type: 'success', + duration: 1500, + onClose: () => { + this.$emit('confirm') + this.visible = false + } + }) + }) + } else { + deviceTypeUpdate(this.dataForm).then(res => { + this.$message({ + message: '淇敼鎴愬姛', + type: 'success', + duration: 1500, + onClose: () => { + this.$emit('confirm') + this.visible = false + } + }) + }) + } + } + } + } +</script> + +<style lang="scss"> + .el-form-item__content { + .el-select,.el-input { + width: 100%; + } + } + .avatar-uploader .el-upload { + border: 1px dashed #d9d9d9; + border-radius: 6px; + cursor: pointer; + position: relative; + overflow: hidden; + } + .avatar-uploader .el-upload:hover { + border-color: #409EFF; + } + .avatar-uploader-icon { + font-size: 28px; + color: #8c939d; + width: 178px; + height: 178px; + line-height: 178px; + text-align: center; + } + .avatar { + width: 178px; + height: 178px; + display: block; + } +</style> diff --git a/src/container/deviceType/index.vue b/src/container/deviceType/index.vue index 0986b26..3878c1c 100644 --- a/src/container/deviceType/index.vue +++ b/src/container/deviceType/index.vue @@ -80,9 +80,9 @@ this.$refs.list.pageQuery(this.queryInfo) }, add() { - this.row = {} + this.row = {id:''} this.addOrUpdateVisible = true - console.log(this.addOrUpdateVisible); + }, close() { this.addOrUpdateVisible = false -- Gitblit v1.9.3