From 9c094a1fe3e1ae3dadef6433f8401818fe2b8304 Mon Sep 17 00:00:00 2001 From: lzhe <lzhe@example.com> Date: 星期五, 21 六月 2024 10:53:43 +0800 Subject: [PATCH] 1 --- src/views/mdc/configComp/Board.vue | 155 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 138 insertions(+), 17 deletions(-) diff --git a/src/views/mdc/configComp/Board.vue b/src/views/mdc/configComp/Board.vue index 5169ee3..7b1189d 100644 --- a/src/views/mdc/configComp/Board.vue +++ b/src/views/mdc/configComp/Board.vue @@ -1,7 +1,7 @@ <!-- * @Date: 2024-04-15 23:58:36 * @LastEditors: Sneed - * @LastEditTime: 2024-04-16 00:26:46 + * @LastEditTime: 2024-04-17 00:45:20 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/mdc/configComp/Board.vue --> <template> @@ -11,37 +11,40 @@ 椤甸潰鎺掑垪鏂瑰紡 </el-col> <el-col :span="4"> - <el-radio-group v-model="radio"> - <el-radio :label="1">鍏呮弧灞忓箷</el-radio> - <el-radio :label="2">璁剧疆琛屽垪</el-radio> + <el-radio-group v-model="form.way" @change="submit('mdc.realtime.setting')"> + <el-radio label="1">鍏呮弧灞忓箷</el-radio> + <el-radio label="2">璁剧疆琛屽垪</el-radio> </el-radio-group> </el-col> <el-col :span="2" class="label" :offset="2"> 璁剧疆琛屾暟 </el-col> <el-col :span="4"> - <el-input-number v-model="radio" :min="1" :max="4" @change="handleChange" /> + <el-input-number @change="submit('mdc.realtime.setting')" v-model="form.line" :min="1" :max="4" /> </el-col> <el-col :span="2" class="label" :offset="2"> 璁剧疆鍒楁暟 </el-col> <el-col :span="4"> - <el-input-number v-model="radio" :min="1" :max="4" @change="handleChange" /> + <el-input-number @change="submit('mdc.realtime.setting')" v-model="form.column" :min="1" :max="5" /> </el-col> <el-col class="title"> 涓嬮潰闄堝垪鎷ユ湁鏍囩鐨勬墍鏈夊伐浣嶇粍锛岃閫夋嫨闇�瑕佸湪瀹炴椂鐪嬫澘椤甸潰鏌ヨ鐨勭粍锛屽苟璁惧畾涓�涓粯璁ょ粍 濡傛灉鏈厤缃煡璇㈢粍锛屽疄鏃跺伐鍐甸〉闈㈤粯璁ゆ煡璇㈡墍鏈夊伐浣� </el-col> - <el-col :span="2" class="label-title"> - 鏌旀�т骇绾� + </el-row> + <el-row v-for="item in dictsNew" :key="item.dictKey"> + <el-col :span="24" class="label-title"> + {{ item.dictValue }} </el-col> - <el-col> + <el-col :span="6" v-for="(v, i) in item.children" :key="v.id" :offset="i > 0 ? 2 : 0"> <el-card class="my-card" @click="radio = true"> <template #header> <div class="card-header"> - <div class="card-line"><el-checkbox v-model="radio" /><span>鍗冩枃绉戞妧</span> - <el-button style="margin-left: auto">璁句负榛樿</el-button> - <el-button style="margin-left: auto">榛樿</el-button> + <div class="card-line"><el-checkbox :disabled="v.isDefault" @change="submit1" + v-model="v.isSelect" /><span>鍗冩枃绉戞妧</span> + <el-button v-if="v.isDefault" style="margin-left: auto">榛樿</el-button> + <el-button @click="setDefault(v)" v-else style="margin-left: auto">璁句负榛樿</el-button> </div> </div> </template> @@ -49,7 +52,7 @@ </el-card> </el-col> - <el-col class="label-title"> + <!-- <el-col class="label-title"> 杞﹂棿 </el-col> <el-col :span="6"> @@ -78,18 +81,136 @@ </template> <p>鎵�鏈夌殑 > 鍗冩枃绉戞妧</p> </el-card> - </el-col> + </el-col> --> </el-row> </el-main> </template> <script> export default { - data() { - return { - radio: '' + computed: { + dictsNew() { + return this.dicts.filter(v => v?.children?.length > 0) } }, + data() { + return { + form: { + id: '', + way: '1', + line: 1, + column: 1, + }, + id: '', + dicts: [] + } + }, + created() { + this.init() + this.getDetail('mdc.realtime.setting', this.form) + }, + methods: { + init() { + this.$HTTP.get('/api/blade-system/param-biz/detail?paramKey=mdc_chosen_groups').then(re => { + this.id = re.data.id + let chosen = [] + let normalId = '' + try { + chosen = JSON.parse(re.data.paramValue).map(v => v.groupId) + normalId = JSON.parse(re.data.paramValue).find(v => v.isDefault).groupId + } catch (error) { + + } + Promise.all([ + this.$HTTP.get('/api/blade-system/dict/dictionary?code=group_tag').then(res => { + this.dicts = [] + this.dicts.push(...res.data.map(({ dictKey, dictValue }) => ({ + dictKey, dictValue + }))) + }), + this.$HTTP.get('/api/blade-system/dict/dictionary?code=beltline_type').then(res => { + this.dicts.push(...res.data.map(({ dictKey, dictValue }) => ({ + dictKey, dictValue + }))) + }) + ]).then(res => { + this.$HTTP.get('/api/blade-cps/apply-settings/list-workstation-group?groupCategory=&groupTag=&groupType=group_workstation').then(res => { + this.dicts.forEach(v => { + v.children = res.data.filter(item => item.groupTag == v.dictKey).map(item => { + return { + groupId: item.id, + groupName: item.name, + groupCode: item.code, + isDefault: item.id === normalId, + isSelect: chosen.indexOf(item.id) > -1 + } + }) + }) + }) + + }) + }) + + }, + getDetail(paramKey, obj) { + this.$HTTP.get('/api/blade-system/param/detail', { paramKey }).then(res => { + Object.keys(obj).forEach(key => { + try { + obj[key] = JSON.parse(res.data.paramValue)[key] + } catch (error) { + console.error(error) + } + }) + obj.id = res.data.id + }) + }, + submit(paramKey) { + let paramValue = { + ...this.form + } + delete paramValue.id + paramValue = JSON.stringify(paramValue) + this.$HTTP.post('/api/blade-system/param/submit', { id: this.form.id, paramKey, paramValue }).then(res => { + if (res.code === 200) { + this.$message.success(`鎿嶄綔鎴愬姛`) + this.getDetail('mdc.realtime.setting', this.form) + } + }) + }, + submit1() { + let paramValue = [] + this.dictsNew.forEach(v => { + let children = v?.children?.filter(item => item.isSelect) || [] + children = children.map(item => { + let current = { ...item } + delete current.isSelect + return current + }) + paramValue.push(...children) + }) + paramValue = JSON.stringify(paramValue) + this.$HTTP.post('/api/blade-system/param-biz/submit', { id: this.id, paramKey: 'mdc_chosen_groups', paramValue }).then(res => { + if (res.code === 200) { + this.$message.success(`鎿嶄綔鎴愬姛`) + this.init() + } + + }) + }, + setDefault({ groupId }) { + this.dicts.forEach(item => { + item?.children.forEach(v => { + if (groupId == v.groupId) { + v.isDefault = true + v.isSelect = true + } else { + v.isDefault = 0 + } + }) + }) + this.submit1() + } + } } </script> -- Gitblit v1.9.3