2026-06-02 11:25:26 +08:00
|
|
|
<template>
|
|
|
|
|
<el-dialog
|
2026-06-25 00:14:40 +08:00
|
|
|
:title="title"
|
2026-06-02 11:25:26 +08:00
|
|
|
:visible.sync="visible"
|
|
|
|
|
:append-to-body="true"
|
|
|
|
|
:close-on-click-modal="false"
|
|
|
|
|
:before-close="handleClose"
|
|
|
|
|
:width="width"
|
|
|
|
|
>
|
|
|
|
|
<div class="setting-content">
|
|
|
|
|
<el-alert
|
|
|
|
|
:title="settingTip"
|
|
|
|
|
type="info"
|
|
|
|
|
:closable="false"
|
|
|
|
|
show-icon
|
|
|
|
|
/>
|
2026-06-04 17:07:15 +08:00
|
|
|
<div class="setting-meta">
|
|
|
|
|
<el-tag v-if="type" type="warning" size="mini">{{ type }}</el-tag>
|
|
|
|
|
<el-tag v-if="code" type="info" size="mini">{{ code }}</el-tag>
|
2026-06-02 11:25:26 +08:00
|
|
|
</div>
|
2026-06-04 17:07:15 +08:00
|
|
|
<el-input
|
|
|
|
|
v-model="jsonText"
|
|
|
|
|
type="textarea"
|
|
|
|
|
:rows="16"
|
|
|
|
|
resize="vertical"
|
|
|
|
|
:placeholder="jsonPlaceholder"
|
|
|
|
|
/>
|
2026-06-02 11:25:26 +08:00
|
|
|
</div>
|
|
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
|
|
<el-button @click="handleClose">{{ $t(key('cancel')) }}</el-button>
|
|
|
|
|
<el-button type="primary" @click="handleSubmit">{{ $t(key('confirm')) }}</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import { i18nMixin } from '@/composables/useI18n'
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: 'ProcessStepSettingDialog',
|
|
|
|
|
mixins: [i18nMixin('page.production_master_data.process_model.process_step')],
|
|
|
|
|
props: {
|
|
|
|
|
type: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: ''
|
|
|
|
|
},
|
|
|
|
|
code: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: ''
|
|
|
|
|
},
|
|
|
|
|
title: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: ''
|
|
|
|
|
},
|
|
|
|
|
width: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: '50%'
|
|
|
|
|
},
|
|
|
|
|
visible: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: false
|
|
|
|
|
},
|
|
|
|
|
pluginData: {
|
|
|
|
|
default: ''
|
|
|
|
|
}
|
|
|
|
|
},
|
2026-06-04 17:07:15 +08:00
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
jsonText: ''
|
|
|
|
|
}
|
|
|
|
|
},
|
2026-06-02 11:25:26 +08:00
|
|
|
computed: {
|
|
|
|
|
settingTip () {
|
|
|
|
|
return this.$t(this.key('setting_tip'))
|
2026-06-04 17:07:15 +08:00
|
|
|
},
|
|
|
|
|
jsonPlaceholder () {
|
|
|
|
|
return '{\n "key": "value"\n}'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
visible: {
|
|
|
|
|
handler (val) {
|
|
|
|
|
if (val) {
|
|
|
|
|
this.resetJsonText()
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
immediate: true
|
|
|
|
|
},
|
|
|
|
|
pluginData: {
|
|
|
|
|
handler () {
|
|
|
|
|
if (this.visible) {
|
|
|
|
|
this.resetJsonText()
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
deep: true
|
2026-06-02 11:25:26 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
2026-06-04 17:07:15 +08:00
|
|
|
resetJsonText () {
|
|
|
|
|
const data = this.pluginData
|
|
|
|
|
if (data === undefined || data === null || data === '') {
|
|
|
|
|
this.jsonText = '{}'
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (typeof data === 'string') {
|
|
|
|
|
this.jsonText = data.trim() ? data : '{}'
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
this.jsonText = JSON.stringify(data, null, 2)
|
|
|
|
|
},
|
2026-06-02 11:25:26 +08:00
|
|
|
handleClose () {
|
|
|
|
|
this.$emit('close')
|
|
|
|
|
},
|
|
|
|
|
handleSubmit () {
|
2026-06-04 17:07:15 +08:00
|
|
|
const raw = (this.jsonText || '').trim()
|
|
|
|
|
if (!raw) {
|
|
|
|
|
this.$emit('submit', {})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
const parsed = JSON.parse(raw)
|
|
|
|
|
this.$emit('submit', parsed)
|
|
|
|
|
} catch (error) {
|
|
|
|
|
this.$message.error('JSON 格式不正确')
|
|
|
|
|
}
|
2026-06-02 11:25:26 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
.setting-content {
|
|
|
|
|
padding: 10px 0;
|
|
|
|
|
}
|
2026-06-04 17:07:15 +08:00
|
|
|
.setting-meta {
|
|
|
|
|
margin: 16px 0 12px;
|
|
|
|
|
display: flex;
|
|
|
|
|
gap: 8px;
|
2026-06-02 11:25:26 +08:00
|
|
|
}
|
|
|
|
|
</style>
|