|
@@ -0,0 +1,196 @@
|
|
|
+<template>
|
|
|
+ <div class="alert-body__main_content">
|
|
|
+ <zz-form :cols="formCols" :data="formData" :rules="formRules" :errors="formErrors" labelWidth="150" ref="form">
|
|
|
+ <div slot="picture" class="clickUpload">
|
|
|
+ <div class="clickUpText">
|
|
|
+ <img class="dataImg" v-if="!!formData.picture" :src="formData.picture" />
|
|
|
+ <template v-else>
|
|
|
+ <div class="addImg"><i class="el-icon-plus"></i></div>
|
|
|
+ </template>
|
|
|
+ </div>
|
|
|
+ <el-upload
|
|
|
+ :headers="token"
|
|
|
+ ref="uploadImg"
|
|
|
+ limit="1"
|
|
|
+ action="/sc-community/upload/uploadFile"
|
|
|
+ :on-success="uploadsuccess"
|
|
|
+ :before-upload="beforeAvatarUpload"
|
|
|
+ :auto-upload="true"
|
|
|
+ name="file"
|
|
|
+ >
|
|
|
+ </el-upload>
|
|
|
+ </div>
|
|
|
+ </zz-form>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+export default {
|
|
|
+ props: ['params'],
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ formData: {
|
|
|
+ area:"",
|
|
|
+ environmentTemperature:"",
|
|
|
+ indoorTemperature:"",
|
|
|
+ installedCapacity:"",
|
|
|
+ picture:"",
|
|
|
+ projectName:"",
|
|
|
+ refrigerationCapacity:"",
|
|
|
+ standardCop:"",
|
|
|
+ totalPower:""
|
|
|
+ },
|
|
|
+ formCols: [
|
|
|
+ [
|
|
|
+ {
|
|
|
+ label: '项目名称',
|
|
|
+ prop: 'projectName',
|
|
|
+ input: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '项目图片',
|
|
|
+ prop: 'picture',
|
|
|
+ slot: 'picture'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '管控面积(㎡)',
|
|
|
+ prop: 'area',
|
|
|
+ input: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '基准COP',
|
|
|
+ prop: 'standardCop',
|
|
|
+ input: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '装机数量(台)',
|
|
|
+ prop: 'installedCapacity',
|
|
|
+ input: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '装机总制冷量(kw)',
|
|
|
+ prop: 'refrigerationCapacity',
|
|
|
+ input: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '总装机功率(kw)',
|
|
|
+ prop: 'totalPower',
|
|
|
+ input: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '环境温度(℃)',
|
|
|
+ prop: 'environmentTemperature',
|
|
|
+ input: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '室内平均温度(℃)',
|
|
|
+ prop: 'indoorTemperature',
|
|
|
+ input: true
|
|
|
+ },
|
|
|
+ ]
|
|
|
+ ],
|
|
|
+ formRules: {
|
|
|
+ area: [this.$valid.inputRequired('管控面积')],
|
|
|
+ environmentTemperature: [this.$valid.inputRequired('环境温度')],
|
|
|
+ indoorTemperature: [this.$valid.inputRequired('室内平均温度')],
|
|
|
+ installedCapacity: [this.$valid.inputRequired('装机数量')],
|
|
|
+ picture: [this.$valid.inputRequired('项目图片')],
|
|
|
+ projectName: [this.$valid.inputRequired('项目名称')],
|
|
|
+ refrigerationCapacity: [this.$valid.inputRequired('装机总制冷量')],
|
|
|
+ standardCop: [this.$valid.inputRequired('基准COP')],
|
|
|
+ totalPower: [this.$valid.inputRequired('总装机功率')]
|
|
|
+ },
|
|
|
+ token: {
|
|
|
+ [localStorage.getItem('SC_token') && 'Authorization']: 'Bearer ' + localStorage.getItem('SC_token')
|
|
|
+ },
|
|
|
+ formErrors: {},
|
|
|
+ };
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ uploadsuccess(response, file, fileList) {
|
|
|
+ this.$refs.uploadImg.clearFiles();
|
|
|
+ if (0 === response.status) {
|
|
|
+ this.formData.picture = response.data;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ beforeAvatarUpload(file) {
|
|
|
+ // const isJPG = file.type === 'image/jpeg';
|
|
|
+ const isLt2M = file.size / 1024 / 1024 < 2;
|
|
|
+
|
|
|
+ // if (!isJPG) {
|
|
|
+ // this.$message.error('上传头像图片只能是 JPG 格式!');
|
|
|
+ // }
|
|
|
+ if (!isLt2M) {
|
|
|
+ this.$message.error('上传头像图片大小不能超过 2MB!');
|
|
|
+ }
|
|
|
+ return isLt2M;
|
|
|
+ },
|
|
|
+ submit() {
|
|
|
+ new Promise((resolve) => {
|
|
|
+ this.$refs.form.validate(resolve);
|
|
|
+ }).then(() => {
|
|
|
+ var loading = this.$loading();
|
|
|
+ let url = '/sc-energy/project/add';
|
|
|
+ if (this.params.todo == 'edit') {
|
|
|
+ url = '/sc-energy/project/edit';
|
|
|
+ }
|
|
|
+ this.$http
|
|
|
+ .post(url, this.formData)
|
|
|
+ .then(({ status, msg }) => {
|
|
|
+ if (status == 0) {
|
|
|
+ this.$message.success(msg);
|
|
|
+ this.params.callback();
|
|
|
+ this.$emit('close');
|
|
|
+ }
|
|
|
+ loading.close();
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ loading.close();
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ if (this.params.todo == 'edit') {
|
|
|
+ this.formData = this.params.data;
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|
|
|
+<style lang="scss" scoped>
|
|
|
+.clickUpload {
|
|
|
+ width: 72px;
|
|
|
+ height: 72px;
|
|
|
+ border-radius: 4px;
|
|
|
+ border: 1px solid #e0e1e3;
|
|
|
+ position: relative;
|
|
|
+ z-index: 1000;
|
|
|
+ text-align: center;
|
|
|
+ overflow: hidden;
|
|
|
+ font-size: 12px;
|
|
|
+ cursor: pointer;
|
|
|
+ color: #d8d8d8;
|
|
|
+ .mini-upload {
|
|
|
+ position: absolute;
|
|
|
+ z-index: 0;
|
|
|
+ }
|
|
|
+}
|
|
|
+.clickUpText {
|
|
|
+ height: 100%;
|
|
|
+ width: 100%;
|
|
|
+ pointer-events: none;
|
|
|
+ position: absolute;
|
|
|
+ background: white;
|
|
|
+ z-index: 1;
|
|
|
+ img.dataImg {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ object-fit: cover;
|
|
|
+ }
|
|
|
+ .addImg {
|
|
|
+ line-height: 72px;
|
|
|
+ & > i {
|
|
|
+ font-size: 30px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|