zxl
2026-03-20 155dbc01da52ccee7a968bfe7297b5fc0357e6bb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<template>
  <a-card :bordered="false">
    <h3>系统配置</h3>
    <a-form-model :model="queryForm" ref="ruleForm" :rules="rules">
      <a-form-model-item
        ref="systemName"
        prop="systemName"
        :label-col="formItemLayout.labelCol"
        :wrapper-col="formItemLayout.wrapperCol"
        label="系统名称"
      >
        <a-input
          v-model="queryForm.systemName"
          :maxLength="10"
          placeholder="请输入系统名称,最多输入10个字"
          allowClear
        />
      </a-form-model-item>
      <a-form-model-item
        ref="operationViewName"
        prop="operationViewName"
        :label-col="formItemLayout.labelCol"
        :wrapper-col="formItemLayout.wrapperCol"
        label="运营大屏名称"
      >
        <a-input
          v-model="queryForm.operationViewName"
          :maxLength="10"
          placeholder="请输入运营大屏名称,最多输入10个字"
          allowClear
        />
      </a-form-model-item>
      <a-form-model-item
        ref="taskViewName"
        prop="taskViewName"
        :label-col="formItemLayout.labelCol"
        :wrapper-col="formItemLayout.wrapperCol"
        label="告警大屏名称"
      >
        <a-input
          v-model="queryForm.taskViewName"
          :maxLength="10"
          placeholder="请输入告警大屏名称,最多输入10个字"
          allowClear
        />
      </a-form-model-item>
      <a-form-model-item
        :label-col="formItemLayout.labelCol"
        :wrapper-col="formItemLayout.wrapperCol"
        label="logo"
        prop="logoPath"
      >
        <a-upload
          name="avatar"
          list-type="picture-card"
          class="avatar-uploader"
          :show-upload-list="false"
          :before-upload="beforeUpload"
          :customRequest="uploadLogoFiles"
          style="position: relative"
        >
          <img class="upload-img" v-if="queryForm.logoPath" :src="staticUrl + queryForm.logoPath" alt="avatar" />
          <div v-else>
            <a-icon :type="logoLoading ? 'loading' : 'plus'" />
          </div>
          <a-icon
            v-if="queryForm.logoPath"
            @click.stop="delLogo"
            style="position: absolute; left: 120px; top: -5px; color: red; z-index: 999"
            type="close"
          />
        </a-upload>
      </a-form-model-item>
      <a-form-model-item
        :label-col="formItemLayout.labelCol"
        :wrapper-col="formItemLayout.wrapperCol"
        label="大屏图片"
        prop="bigDataPath"
      >
        <a-upload
          name="avatar"
          list-type="picture-card"
          class="avatar-uploader"
          :show-upload-list="false"
          :before-upload="beforeUpload"
          :customRequest="uploadBgFiles"
          style="position: relative"
        >
          <img class="upload-img" v-if="queryForm.bigDataPath" :src="staticUrl + queryForm.bigDataPath" alt="avatar" />
          <div v-else>
            <a-icon :type="bgLoading ? 'loading' : 'plus'" />
          </div>
          <a-icon
            v-if="queryForm.bigDataPath"
            @click.stop="delBigDataPath"
            style="position: absolute; left: 120px; top: -5px; color: red; z-index: 999"
            type="close"
          />
        </a-upload>
      </a-form-model-item>
      <a-form-model-item :label-col="formTailLayout.labelCol" :wrapper-col="formTailLayout.wrapperCol">
        <a-button type="primary" @click="onSubmit"> 保存</a-button>
      </a-form-model-item>
    </a-form-model>
  </a-card>
</template>
 
<script>
import { clearEmptyPro } from '@/utils/util'
import { uploadAction, putAction, getAction } from '@tievd/cube-block/lib/api/manage'
 
const formItemLayout = {
  labelCol: { span: 2 },
  wrapperCol: { span: 6 },
}
const formTailLayout = {
  labelCol: { span: 4 },
  wrapperCol: { span: 8, offset: 4 },
}
 
export default {
  created() {
    this.init()
  },
  data() {
    return {
      staticUrl: window._CONFIG['staticDomainURL'],
      formItemLayout,
      formTailLayout,
      logoLoading: false,
      bgLoading: false,
      queryForm: {},
      rules: {
        systemName: [{ required: true, message: '请输入系统名称', trigger: 'blur' }],
        taskViewName: [{ required: true, message: '请输入告警大屏名称', trigger: 'blur' }],
        operationViewName: [{ required: true, message: '请输入运营大屏名称', trigger: 'blur' }],
      },
      url: {
        query: '/jyz/sysInfo/localInfo',
        upload: '/jyz/sysInfo/uploadLogo',
        edit: '/jyz/sysInfo/edit',
      },
    }
  },
  methods: {
    delLogo() {
      this.queryForm.logoPath = ''
    },
    delBigDataPath() {
      this.queryForm.bigDataPath = ''
    },
    //初始化 查询系统信息
    init() {
      getAction(this.url.query, {}).then((res) => {
        if (res.code === 200) {
          this.queryForm = res.result
        } else {
          this.$message.error(res.message)
        }
      })
    },
    onSubmit() {
      this.$refs.ruleForm.validate((valid) => {
        if (valid) {
          // 深拷贝一份数据
          let params = JSON.parse(JSON.stringify(this.queryForm))
          putAction(this.url.edit, clearEmptyPro(params)).then((res) => {
            if (res.code == 200) {
              this.$message.success('操作成功,重新登录后生效')
              this.init()
            } else {
              this.$message.error(res.message)
            }
          })
        } else {
          this.$message.error('请完善信息')
          return false
        }
      })
    },
    uploadLogoFiles(info) {
      this.logoLoading = true
      let formData = new FormData()
      formData.append('file', info.file)
      formData.append('type', 1)
      uploadAction(this.url.upload, formData).then((res) => {
        if (res.code === 200) {
          this.logoLoading = false
          this.queryForm.logoPath = res.result
        } else {
          this.logoLoading = false
          this.$message.error(res.message)
        }
      })
    },
    uploadBgFiles(info) {
      this.bgLoading = true
      let formData = new FormData()
      formData.append('file', info.file)
      formData.append('type', 3)
      uploadAction(this.url.upload, formData).then((res) => {
        if (res.code === 200) {
          this.bgLoading = false
          this.queryForm.bigDataPath = res.result
        } else {
          this.bgLoading = false
          this.$message.error(res.message)
        }
      })
    },
    beforeUpload(file) {
      const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'
      if (!isJpgOrPng) {
        this.$message.error('You can only upload JPG file!')
      }
      const isLt2M = file.size / 1024 / 1024 < 2
      if (!isLt2M) {
        this.$message.error('Image must smaller than 2MB!')
      }
      return isJpgOrPng && isLt2M
    },
  },
}
</script>
 
<style lang="less" scoped>
.upload-img {
  width: 102px;
  height: 102px;
  object-fit: cover;
}
.ant-card {
  margin-right: 20px;
  background: linear-gradient(40deg, rgba(38, 43, 53, 0.6), rgba(31, 35, 43, 0.6));
}
</style>