wms_client_kate_suzhou/src/layout/wmsConfig.vue

265 lines
11 KiB
Vue
Raw Normal View History

2024-08-01 16:39:00 +08:00
<template>
<div style="margin-bottom: 10px">
<el-config-provider :locale="zhCn">
<el-row>
<el-input v-model="configNameQuery" style="width: 256px; margin-right: 10px;" placeholder="配置名称"
:suffix-icon="Search" />
<el-button type="primary" @click="search()">搜索</el-button>
<el-button type="warning" @click="reset()">重置</el-button>
</el-row>
<br />
2024-08-02 23:10:15 +08:00
<el-table :data="configList" stripe border v-loading="loading" class="table-class" max-height="550px"
highlight-current-row @row-click="getCurrentRow" :header-cell-style="{ 'text-align': 'center' }"
:cell-style="{ 'text-align': 'center' }">
2024-08-01 16:39:00 +08:00
<el-table-column width="65px" fixed="left">
<template v-slot="scope">
2024-08-02 23:10:15 +08:00
<el-radio :label="scope.row.configId" v-model="configId">&nbsp;</el-radio>
2024-08-01 16:39:00 +08:00
</template>
</el-table-column>
2024-08-02 23:10:15 +08:00
<el-table-column prop="configId" label="配置id" fixed="left" min-width="80px" show-overflow-tooltip />
<el-table-column prop="configName" label="配置名称" fixed="left" min-width="120px" show-overflow-tooltip />
<el-table-column prop="configKey" label="配置键" show-overflow-tooltip min-width="120px" />
<el-table-column prop="configValue" label="配置值" show-overflow-tooltip min-width="140px" />
<el-table-column prop="configType" label="配置类型" :formatter="configTypeFormat" min-width="100px"
show-overflow-tooltip />
<el-table-column fixed="right" label="操作" width="120px">
2024-08-01 16:39:00 +08:00
<template v-slot="scope">
<el-button plain type="primary" @click="editCurrentRow(scope.row)">编辑</el-button>
2024-08-01 16:39:00 +08:00
</template>
2024-08-02 23:10:15 +08:00
</el-table-column>
2024-08-01 16:39:00 +08:00
</el-table>
<br />
<el-pagination v-model:current-page="currentPage" v-model:page-size="pageSize" :page-sizes="[10, 25, 50]"
:small="false" :disabled="false" :background="false" :default-page-size="10" @size-change="search"
@current-change="search" layout="total, sizes, prev, pager, next, jumper" :total="total" />
<el-dialog v-model="dialogVisible" title="库存信息" width="40%" draggable :show-close="false">
2024-08-02 23:10:15 +08:00
<el-form ref="configFormRef" :model="configFormEntity" :label-position="labelPosition"
label-width="100px" style="max-width: 100%" :rules="rules" status-icon>
2024-08-01 16:39:00 +08:00
<el-row :gutter="16">
<el-col :span="12" :offset="0">
2024-08-02 23:10:15 +08:00
<el-form-item label="配置名称" prop="configName">
<el-input v-model="configFormEntity.configName" disabled />
2024-08-01 16:39:00 +08:00
</el-form-item>
</el-col>
<el-col :span="12">
2024-08-02 23:10:15 +08:00
<el-form-item label="配置类型" prop="configType">
<el-select-v2 v-model="configFormEntity.configType" placeholder="请选择配置类型"
:options="configTypeOptions" disabled></el-select-v2>
2024-08-01 16:39:00 +08:00
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12" :offset="0">
2024-08-02 23:10:15 +08:00
<el-form-item label="配置键" prop="configKey">
<el-input v-model="configFormEntity.configKey" disabled />
2024-08-01 16:39:00 +08:00
</el-form-item>
</el-col>
<el-col :span="12">
2024-08-02 23:10:15 +08:00
<el-form-item label="配置值" prop="configValue">
<el-input v-if="configFormEntity.configType == '1'" type="textarea" :rows="1"
v-model="configFormEntity.configValue" placeholder="" :maxlength="-1"
:show-word-limit="false" :autosize="{ minRows: 1, maxRows: 4 }">
</el-input>
<el-select v-if="configFormEntity.configType == '2'"
v-model="configFormEntity.configValue" multiple collapse-tags collapse-tags-tooltip
:placeholder="'请选择' + configFormEntity.configName">
<el-option v-for="(value, index) in mails" :key="index" :label="value"
:value="value" />
</el-select>
<el-switch v-if="configFormEntity.configType == '3'" style="margin-left: 5px;"
v-model="configFormEntity.configValue" active-value="1" inactive-value="0" />
2024-08-01 16:39:00 +08:00
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="dialogVisible = false">取消</el-button>
2024-08-02 23:10:15 +08:00
<el-button type="primary" @click="submitChange()">
2024-08-01 16:39:00 +08:00
确定
</el-button>
</span>
</template>
</el-dialog>
</el-config-provider>
</div>
</template>
<script setup>
2024-08-02 23:10:15 +08:00
import { getConfigsByPage, updateConfig } from '@/api/config.js'
import { configTypeFormatter } from '@/utils/formatter.js'
2024-08-01 16:39:00 +08:00
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import { Search } from '@element-plus/icons-vue'
import { ref, reactive } from 'vue'
import { ElMessage } from 'element-plus'
</script>
<script>
export default {
name: 'wmsConfig',
2024-08-01 16:39:00 +08:00
data() {
return {
pageInfo: {},
2024-08-02 23:10:15 +08:00
configList: [],
2024-08-01 16:39:00 +08:00
currentPage: 1,
pageSize: 10,
total: 0,
configNameQuery: '',
2024-08-02 23:10:15 +08:00
loading: false,
configId: '',
configFormRef: ref(),
configFormEntity: reactive({}),
2024-08-01 16:39:00 +08:00
rules: reactive({
2024-08-02 23:10:15 +08:00
configId: [
{ required: true, message: '请输入配置id' }
2024-08-01 16:39:00 +08:00
],
2024-08-02 23:10:15 +08:00
configName: [
{ required: true, message: '请输入配置名称' }
2024-08-01 16:39:00 +08:00
],
2024-08-02 23:10:15 +08:00
configKey: [
{ required: true, message: '请输入配置键' }
2024-08-01 16:39:00 +08:00
],
2024-08-02 23:10:15 +08:00
configValue: [
{ required: true, message: '请输入配置值' }
2024-08-01 16:39:00 +08:00
],
2024-08-02 23:10:15 +08:00
configType: [
{ required: true, message: '请输入配置类型' }
2024-08-01 16:39:00 +08:00
]
}),
labelPosition: 'top',
dialogVisible: false,
2024-08-02 23:10:15 +08:00
configTypeOptions: [
2024-08-01 16:39:00 +08:00
{
2024-08-02 23:10:15 +08:00
value: '1',
label: '输入框'
2024-08-01 16:39:00 +08:00
},
{
2024-08-02 23:10:15 +08:00
value: '2',
label: '下拉多选'
2024-08-01 16:39:00 +08:00
},
{
2024-08-02 23:10:15 +08:00
value: '3',
label: '开关'
2024-08-01 16:39:00 +08:00
}
],
2024-08-02 23:10:15 +08:00
mails: []
2024-08-01 16:39:00 +08:00
}
},
mounted() {
this.search()
},
methods: {
2024-08-02 23:10:15 +08:00
configTypeFormat: (row, column, cellValue, index) => {
return configTypeFormatter(cellValue)
2024-08-01 16:39:00 +08:00
},
search() {
this.loading = true
const request = {
pageNo: this.currentPage,
pageSize: this.pageSize,
configName: this.configNameQuery.trim(),
userName: store.getters.getUserName
2024-08-01 16:39:00 +08:00
}
2024-08-02 23:10:15 +08:00
getConfigsByPage(request).then(res => {
2024-08-01 16:39:00 +08:00
const tableResponse = res.data
2024-08-02 23:10:15 +08:00
if (tableResponse.code == 0) {
this.configList = tableResponse.returnData.lists
this.configList.forEach((config) => {
if (config.configType == '2') {
const tempArray = config.configValue.split(';')
config.configValue = tempArray
}
if (config.configKey == 'MAIL_ADDRESS') {
const tempArray = config.configValue.split(';')
this.mails = tempArray
}
})
2024-08-02 23:10:15 +08:00
this.total = tableResponse.returnData.total
} else {
2024-08-01 16:39:00 +08:00
ElMessage.error(tableResponse.message)
}
}).catch(err => {
console.log(err)
2024-08-02 23:10:15 +08:00
ElMessage.error('查询配置错误')
2024-08-01 16:39:00 +08:00
})
this.loading = false
},
reset() {
2024-08-02 23:10:15 +08:00
this.configNameQuery = ''
2024-08-01 16:39:00 +08:00
this.search()
},
getCurrentRow(row) {
2024-08-02 23:10:15 +08:00
this.configId = row.configId
2024-08-01 16:39:00 +08:00
},
editCurrentRow(row) {
2024-08-02 23:10:15 +08:00
this.configFormEntity = reactive({
configId: row.configId,
configName: row.configName,
configKey: row.configKey,
configValue: row.configValue,
configType: row.configType
})
2024-08-01 16:39:00 +08:00
this.dialogVisible = true
},
2024-08-02 23:10:15 +08:00
submitChange() {
const request = {
configId: this.configFormEntity.configId,
configName: this.configFormEntity.configName,
configKey: this.configFormEntity.configKey,
configValue: this.configFormEntity.configValue,
configType: this.configFormEntity.configType,
userName: store.getters.getUserName
2024-08-02 23:10:15 +08:00
}
updateConfig(request).then(res => {
2024-08-01 16:39:00 +08:00
if (res.data.code == 0) {
this.dialogVisible = false
ElMessage({
2024-08-02 23:10:15 +08:00
message: '更新系统配置成功',
2024-08-01 16:39:00 +08:00
type: 'success'
})
this.search()
} else {
ElMessage.error(res.data.message)
}
}).catch(err => {
ElMessage({
2024-08-02 23:10:15 +08:00
message: '更新系统配置失败: ' + err,
2024-08-01 16:39:00 +08:00
type: 'error',
showClose: true
})
})
}
},
}
</script>
<style scoped>
.el-pagination {
padding-left: 5px;
}
.el-row .el-button {
width: 72px;
margin-left: 0px;
margin-right: 5px;
}
.table-class {
width: 100%;
}
.el-row .el-form-item .el-select-v2 {
width: 100% !important;
}
.el-row .el-form-item .el-input-number {
width: 100% !important;
}
.el-row .el-form-item .el-select {
width: 100% !important;
}
.el-row .el-form-item .el-input {
width: 100% !important;
}
2024-08-01 16:39:00 +08:00
</style>