Files
apt-nl/src/pages/modules/systemmanage/system.vue

268 lines
6.9 KiB
Vue
Raw Normal View History

2023-05-16 14:05:07 +08:00
<template>
<div class="right_side">
<div class="buttons_wrapper">
<div class="row">
<button class="button button--primary" @click="showDialog('1')">添加参数</button>
</div>
</div>
<div class="grid_wrapper">
<table>
<tr>
<th>序号</th>
<th>编码</th>
<th>名称</th>
<th></th>
<th>备注</th>
<th>操作</th>
</tr>
<tr v-for="(e, i) in datalist" :key="i">
<td>{{i+1}}</td>
2023-05-24 15:34:50 +08:00
<td>{{ e.code }}</td>
<td>{{ e.name }}</td>
<td>{{ e.value }}</td>
<td>{{ e.remark }}</td>
2023-05-16 14:05:07 +08:00
<td>
<div class="row">
2023-05-24 15:34:50 +08:00
<button class="button button--primary grid_button" @click="showDialog('2', e)">修改</button>
<button class="button button--primary grid_button" @click="showDialog('3', e)">删除</button>
2023-05-16 14:05:07 +08:00
</div>
</td>
</tr>
</table>
</div>
<jxDialog
ref="child"
:title="title"
:type="type"
2023-05-24 15:34:50 +08:00
:unclick="unclick"
2023-05-16 14:05:07 +08:00
@toSure="toSureDialog"
>
<div v-if="type === '1' || type === '2'" class="form_wraper">
<div class="form">
<div class="form_item">
<div class="form_item__label"><i>*</i>编码</div>
<div class="form_item__content">
<input type="text" class="form_item__input" v-model="code">
</div>
</div>
<div class="form_item">
<div class="form_item__label"><i>*</i>名字</div>
<div class="form_item__content">
<input type="text" class="form_item__input" v-model="name">
</div>
</div>
</div>
<div class="form">
<div class="form_item">
<div class="form_item__label"><i>*</i>数值</div>
<div class="form_item__content">
2023-05-24 15:34:50 +08:00
<input type="text" class="form_item__input" v-model="value">
2023-05-16 14:05:07 +08:00
</div>
</div>
</div>
<div class="form">
<div class="form_item allwidth">
<div class="form_item__label">备注</div>
<div class="form_item__content">
<textarea v-model="remark" style="resize:none;" class="form_item__input form_item__textarea"></textarea>
</div>
</div>
</div>
</div>
<div v-if="type === '3'" class="form_wraper">确定删除吗</div>
</jxDialog>
</div>
</template>
<script>
import jxDialog from '@components/dialog.vue'
2023-05-24 15:34:50 +08:00
import { paramQuery, paramAdd, paramEdit, paramDelete } from '@config/getData2.js'
2023-05-16 14:05:07 +08:00
export default {
components: {
jxDialog
},
data () {
return {
2023-05-24 15:34:50 +08:00
datalist: [],
2023-05-16 14:05:07 +08:00
active: false,
type: '',
title: '',
code: '',
name: '',
2023-05-24 15:34:50 +08:00
value: '',
remark: '',
unclick: false
2023-05-16 14:05:07 +08:00
}
},
watch: {
type (val) {
switch (val) {
case '1':
this.title = '添加参数'
break
case '2':
this.title = '修改参数'
break
case '3':
this.title = ''
break
default:
this.title = ''
}
2023-05-24 15:34:50 +08:00
},
code (val) {
if ((this.type === '1' || this.type === '2') && (val === '' || this.name === '' || this.value === '')) {
this.unclick = true
} else {
this.unclick = false
}
},
name (val) {
if ((this.type === '1' || this.type === '2') && (val === '' || this.code === '' || this.value === '')) {
this.unclick = true
} else {
this.unclick = false
}
},
value (val) {
if ((this.type === '1' || this.type === '2') && (val === '' || this.code === '' || this.name === '')) {
this.unclick = true
} else {
this.unclick = false
}
2023-05-16 14:05:07 +08:00
}
},
2023-05-24 15:34:50 +08:00
created () {
this._paramQuery()
},
2023-05-16 14:05:07 +08:00
methods: {
2023-05-24 15:34:50 +08:00
async _paramQuery () {
let res = await paramQuery('0', '100')
this.datalist = [...res]
},
showDialog (type, e) {
2023-05-16 14:05:07 +08:00
this.type = type
this.$refs.child.active = true
2023-05-24 15:34:50 +08:00
switch (type) {
case '1':
this.code = ''
this.name = ''
this.value = ''
this.unclick = true
break
case '2':
this.code = e.code
this.name = e.name
this.value = e.value
if (!this.code || !this.name || !this.value) {
this.unclick = true
} else {
this.unclick = false
}
this.pkObj = e
break
case '3':
this.unclick = false
this.pkObj = e
break
}
2023-05-16 14:05:07 +08:00
},
toSureDialog (type) {
switch (type) {
case '1':
2023-05-24 15:34:50 +08:00
this._paramAdd()
2023-05-16 14:05:07 +08:00
break
case '2':
2023-05-24 15:34:50 +08:00
this._paramEdit()
2023-05-16 14:05:07 +08:00
break
case '3':
2023-05-24 15:34:50 +08:00
this._paramDelete()
2023-05-16 14:05:07 +08:00
break
2023-05-24 15:34:50 +08:00
}
},
async _paramAdd () {
this.$refs.child.disabled = true
if (!this.code) {
this.toast('编码不能为空')
this.$refs.child.disabled = false
return
}
if (!this.name) {
this.toast('名字不能为空')
this.$refs.child.disabled = false
return
}
if (!this.value) {
this.toast('数值不能为空')
this.$refs.child.disabled = false
return
}
try {
let res = await paramAdd(this.code, this.name, this.value, this.remark)
if (res.code === '1') {
this._usersQuery()
}
this.toast(res.desc)
this.$refs.child.active = false
this.$refs.child.disabled = false
} catch (e) {
this.$refs.child.active = false
this.$refs.child.disabled = false
}
},
async _paramEdit () {
this.$refs.child.disabled = true
if (!this.code) {
this.toast('编码不能为空')
this.$refs.child.disabled = false
return
}
if (!this.name) {
this.toast('名字不能为空')
this.$refs.child.disabled = false
return
}
if (!this.value) {
this.toast('数值不能为空')
this.$refs.child.disabled = false
return
}
try {
let res = await paramEdit(this.pkObj.id, this.code, this.name, this.value, this.remark)
if (res.code === '1') {
this._usersQuery()
}
this.toast(res.desc)
this.$refs.child.active = false
this.$refs.child.disabled = false
} catch (e) {
this.$refs.child.active = false
this.$refs.child.disabled = false
}
},
async _paramDelete () {
this.$refs.child.disabled = true
try {
let res = await paramDelete([this.pkObj.id])
if (res.code === '1') {
this._usersQuery()
}
this.toast(res.desc)
this.$refs.child.active = false
this.$refs.child.disabled = false
} catch (e) {
this.$refs.child.active = false
this.$refs.child.disabled = false
2023-05-16 14:05:07 +08:00
}
}
}
}
</script>
<style lang="stylus" scoped>
@import '~@style/mixin'
.grid_wrapper
height calc(100% - 50px)
overflow-y auto
</style>