景区管控小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
jq_miniApp/subPackWork/equipmentManagement/equipmentEdit.vue

355 lines
9.5 KiB

<template>
<view class="v-page">
<view class="v-card contain" style="padding-bottom: 120rpx;">
<evan-form class="v-form" ref="form" :hide-required-asterisk="hideRequiredAsterisk" :model="info">
<view class="v-card-item">
<view class="v-card-box">
<common-title :title="'基础信息'"></common-title>
<evan-form-item label="设备名称:" prop="resourceName">
<input v-model="info.resourceName" class="form-input" placeholder="请输入设备名称"
placeholder-class="form-input-placeholder" />
</evan-form-item>
<evan-form-item label="设备编码:" prop="phone">
<input v-model="info.resourceCode" class="form-input" placeholder="请输入电话"
placeholder-class="form-input-placeholder" />
</evan-form-item>
<evan-form-item label="设备品牌:" prop="classificationDataCode">
<uni-data-picker class="tree-pick" v-model="info.devBrand" :localdata="devBrandData"
placeholder="请选择设备品牌" popup-title="请选择" @change="onchange" @inputclick="inputclick"
@nodeclick="onnodeclick" @popupclosed="onpopupclosed"
@popupopened="onpopupopened"></uni-data-picker>
<!-- <input v-model="info.devBrand" class="form-input" placeholder="请输入标题" placeholder-class="form-input-placeholder" />
--> </evan-form-item>
<evan-form-item label="规格型号:" prop="title">
<uni-data-picker class="tree-pick" :border='false' v-model="info.devModel"
:localdata="devModelData" placeholder="规则型号" popup-title="请选择" @change="onchange"
@inputclick="inputclick" @nodeclick="onnodeclick" @popupclosed="onpopupclosed"
@popupopened="onpopupopened"></uni-data-picker>
</evan-form-item>
<evan-form-item label="采购时间:" prop="title">
<uni-datetime-picker type="date" :clear-icon="false" v-model="info.buyTime"
@maskClick="maskClick" />
</evan-form-item>
<evan-form-item label="地图坐标:" prop="location">
<input v-show="false" v-model="info.location" class="form-input" disabled
placeholder="请选择坐标" placeholder-class="form-input-placeholder" />
<text
v-if="info.lat != '' && info.lon != ''">经度:{{ info.lon || '/' }},纬度:{{ info.lat || '/' }}</text>
<image class="v-card-icon-img" @click="getLocation"
src="@/static/images/icons/icon-position.svg"></image>
</evan-form-item>
</view>
</view>
<view class="v-card-item">
<view class="v-card-box">
<common-title :title="'图片'"></common-title>
<w-upload :show-add="imgList.length<1" ref="wUpload" :token="token" :imgShow="imgShow" :requestUrl="requestUrl"
:imgType="imgType" @updateImgList="updateImgList" :imgList="imgList"
@imgSuccess="imgSuccess"></w-upload>
</view>
</view>
<view class="v-card-item">
<view class="v-card-box">
<evan-form-item label="设备简介:" prop="description">
<input v-model="info.introduction" class="form-input" placeholder="请输入描述"
placeholder-class="form-input-placeholder" />
</evan-form-item>
</view>
</view>
<view class="v-card-item">
<view class="v-card-box">
<evan-form-item label="设备描述:" prop="description">
<piaoyiEditor :values="info.resourceDescribe" :maxlength="3000" @changes="saveContens" />
<!-- <input v-model="info.resourceDescribe" class="form-input" placeholder="请输入描述" placeholder-class="form-input-placeholder" /> -->
</evan-form-item>
</view>
</view>
</evan-form>
</view>
<view class="v-page-button contain">
<button class="v-btn-large" style="width: 100%;" @click="save">保存</button>
</view>
</view>
</template>
<script>
import {
getEnquipmentDetail,
getEquipmentBrandData,
getEquipmentSizeData,
updateEnquipment
} from '@/api/word/equipmentManagement.js'
import wUpload from '@/components/file-img-upload/w-upload.vue';
import piaoyiEditor from '@/components/piaoyi-editor/piaoyi-editor.vue';
import {
getToken
} from '@/utils/auth.js';
import config from '@/config.js';
const baseUrl = config.baseUrl;
export default {
components: {
wUpload,
piaoyiEditor
},
data() {
return {
token: '',
imgShow: true,
requestUrl: baseUrl + '/common/upload',
imgType: 'jpg,png,gif',
imgList: [],
hideRequiredAsterisk: false,
classDataTree: [],
info: {
id: '',
resourceName: '',
resourceCode: '',
devBrand: '',
devModel: '',
buyTime: '',
devModelName: '',
lon: '',
lat: '',
introduction: '',
resourceDescribe: '',
},
devBrandData: [],
devModelData: [],
rules: {
resourceName: [{
required: true,
message: "请填写设备名称",
trigger: "change"
},
{
min: 2,
max: 15,
message: "设备名称长度在2到15个字符",
trigger: "change"
}
]
}
};
},
onShow() {
uni.$off('event');
uni.$on('event', (value) => {
// console.log(value); // some value
(this.info.lon = value.longitude.toFixed(2)),
(this.info.lat = value.latitude.toFixed(2))
});
this.token = getToken();
//this.getWaringList();
// console.log(this.token)
},
onLoad(option) {
let id = option.id;
let type = option.type
// 设备品牌
this.getEquipmentBrandData();
//设备规格
this.getEquipmentSizeData();
// 设备详情
this.getEnquipmentDetail(id, type)
},
mounted() {
this.$refs.form.setRules(this.rules);
},
methods: {
maskClick(val){
console.log(val)
},
// 返回被删除的图片和索引号
updateImgList(val) {
console.log(val);
this.imgList.forEach((i, j) => {
if (j == val[0]) {
this.imgList.splice(j, 1);
this.$forceUpdate(); //强制更新视图
}
});
},
// 返回上传成功的图片信息
imgSuccess(val) {
console.log(val);
this.imgList.push(val);
// this.graphicInfo.coverImg = this.imgList.join(',')
},
onnodeclick(e) {
console.log('nodeclick', e);
},
onpopupopened(e) {
console.log('onpopupopened');
},
onpopupclosed(e) {
console.log('onpopupclosed');
},
onchange(e) {
console.log('onchange', e.detail.value);
},
inputclick(e) {
console.log('inputclick');
},
getLocation() {
uni.navigateTo({
url: '../reportMatter/map'
});
},
// 获取设备详情
getEnquipmentDetail(id, type) {
getEnquipmentDetail(id, type).then(res => {
if (res.code === 200) {
this.info = res.data
this.info.lon = Number(this.info.lon).toFixed(2)
this.info.lat = Number(this.info.lat).toFixed(2)
if (this.info.coverImg) {
this.imgList = this.info.coverImg.split(',')
}
}
})
},
// 获取设备品牌
getEquipmentBrandData() {
getEquipmentBrandData().then(res => {
if (res.code === 200) {
this.devBrandData = res.data
// 数据转换
var arr = [];
if (this.devBrandData && this.devBrandData.length > 0) {
this.devBrandData.forEach((item) => {
var obj = {
text: item.dictLabel,
value: item.dictValue,
children: []
};
if (item.list && item.list.length > 0) {
item.list.forEach((sonItem) => {
var sonObj = {
text: sonItem.dictLabel,
value: sonItem.dictValue
}
obj.children.push(sonObj);
});
}
arr.push(obj);
});
}
this.devBrandData = arr;
}
})
},
// 获取设备规格
getEquipmentSizeData() { //
getEquipmentSizeData().then(res => {
if (res.code === 200) {
this.devModelData = res.data
// 数据转换
var arr = [];
if (this.devModelData && this.devModelData.length > 0) {
this.devModelData.forEach((item) => {
var obj = {
text: item.dictLabel,
value: item.dictValue,
children: []
};
if (item.list && item.list.length > 0) {
item.list.forEach((sonItem) => {
var sonObj = {
text: sonItem.dictLabel,
value: sonItem.dictValue
}
obj.children.push(sonObj);
});
}
arr.push(obj);
});
}
this.devModelData = arr;
}
})
},
save() {
this.$refs.form.validate((res) => {
if (res) {
this.info.graphicInfo = {
coverImg: this.imgList.join(','),
introduction: this.info.introduction,
resourceDescribe: this.info.resourceDescribe
}
updateEnquipment(this.info).then(res => {
if (res.code === 200) {
setTimeout(() => {
uni.showToast({
icon: 'success',
title: '操作成功'
});
//this.$refs.refresh.endAfter(); //刷新结束调用
}, 800)
uni.navigateBack({
delta: 1,
complete: () => {
uni.startPullDownRefresh()
}
});
}
})
}
});
},
saveContens(e) {
this.info.resourceDescribe = e.html || ''
console.log(e)
}
}
};
</script>
<style lang="scss" scoped>
.evan-form-show__button {
position: fixed;
bottom: 20rpx;
width: 94%;
transform: translateX(3%);
background-color: rgb(54, 127, 255);
color: #eee;
}
.uni-input-placeholder {
font-size: 24rpx
}
.set-position {
position: absolute;
right: 20rpx;
}
.tree-pick {
width: 95%;
}
.title-pic {
padding: 10px 21px;
color: #4d4d4d;
}
::v-deep .evan-form-item-container__label {
width: 23%;
padding-left: 20rpx;
}
</style>