<!--
|
* @Date: 2024-04-15 23:58:36
|
* @LastEditors: Sneed
|
* @LastEditTime: 2024-04-17 00:38:24
|
* @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/mdc/configComp/Board.vue
|
-->
|
<template>
|
<el-main>
|
<el-row>
|
<el-col :span="2" class="label">
|
页面排列方式
|
</el-col>
|
<el-col :span="4">
|
<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 @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 @change="submit('mdc.realtime.setting')" v-model="form.column" :min="1" :max="5" />
|
</el-col>
|
<el-col class="title">
|
下面陈列拥有标签的所有工位组,请选择需要在实时看板页面查询的组,并设定一个默认组
|
如果未配置查询组,实时工况页面默认查询所有工位
|
</el-col>
|
</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 :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 :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>
|
<p>所有的 > 千文科技</p>
|
</el-card>
|
</el-col>
|
|
<!-- <el-col class="label-title">
|
车间
|
</el-col>
|
<el-col :span="6">
|
<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>
|
</div>
|
</template>
|
<p>所有的 > 千文科技</p>
|
</el-card>
|
|
</el-col>
|
<el-col :span="6" :offset="2">
|
<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>
|
</div>
|
</template>
|
<p>所有的 > 千文科技</p>
|
</el-card>
|
</el-col> -->
|
</el-row>
|
</el-main>
|
</template>
|
|
<script>
|
export default {
|
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() {
|
console.log('>>>>>>normalId')
|
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
|
console.log('>>>>>>normalId', normalId)
|
} catch (error) {
|
|
}
|
Promise.all([
|
this.$HTTP.get('/api/blade-system/dict/dictionary?code=group_tag').then(res => {
|
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
|
} else {
|
v.isDefault = 0
|
}
|
})
|
})
|
this.submit1()
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.label {
|
display: flex;
|
align-items: center;
|
|
}
|
|
.label-title {
|
margin-bottom: 14px;
|
}
|
|
.my-card {
|
max-width: 480px;
|
cursor: pointer;
|
}
|
|
.title {
|
padding: 10px 0;
|
font-size: 14px;
|
}
|
|
.card-line {
|
display: flex;
|
align-items: center;
|
|
span {
|
margin: 0 10px;
|
}
|
}
|
</style>
|