123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531 |
- <template>
- <view class="appWrapper">
- <!-- 站点新增start -->
- <form action="" @submit="formSubmit" v-if="!deviceCode">
- <view class="form-item margin-top">
- <view class="title">
- <text class="necessary">*</text>
- 设备编号:
- </view>
- <input name="deviceCode" v-model="formMess.deviceCode"></input>
- </view>
- <view class="form-item">
- <view class="title"><text class="necessary">*</text>设备名称:</view>
- <input name="input" v-model="formMess.deviceName"></input>
- </view>
- <view class="form-item">
- <view class="title"><text class="necessary">*</text>安装位置:</view>
- <input name="input" v-model="formMess.deviceInstallationPosition"></input>
- </view>
- <view class="form-item">
- <view class="title"><text class="necessary">*</text>所属楼层:</view>
- <!-- <select name="" id="" v-model="formMess.floor" filterable clearable>
- <option value="1" >楼层1</option>
- <option value="2" >楼层2</option>
- </select> -->
- <select name="" id="" v-model="formMess.floor" filterable clearable>
- <option value="" >请选择</option>
- <option value="-10">楼层B10</option>
- <option value="-9">楼层B9</option>
- <option value="-8">楼层B8</option>
- <option value="-7">楼层B7</option>
- <option value="-6">楼层B6</option>
- <option value="-5">楼层B5</option>
- <option value="-4">楼层B4</option>
- <option value="-3">楼层B3</option>
- <option value="-2">楼层B2</option>
- <option value="-1">楼层B1</option>
- <option :value=item v-for="item in 60">楼层{{item}}</option>
- </select>
- </view>
- <view class="form-item">
- <view class="title"><text class="necessary">*</text>设备类型:</view>
- <select name="" id="" v-model="formMess.deviceType" filterable clearable>
- <option value="">请选择</option>
- <option value="1">智慧用电</option>
- <option value="2">视频监测</option>
- </select>
- </view>
- <view class="form-item">
- <view class="title"><text class="necessary">*</text>站点:</view>
- <select name="" id="" v-model="formMess.siteId" filterable clearable>
- <option value="">请选择</option>
- <option :value=item.id v-for="item in siteList">{{ item.siteName}}</option>
- </select>
- </view>
- <view class="btn-area submitBottomBtn padding-lr-sm">
- <button class="bg-blue round margin-top" @click="$noMultipleClicks(addSubmit)">提 交 </button>
- </view>
- </form>
- <!-- 站点新增end -->
- <!-- 站点修改start -->
- <form action="" @submit="formSubmit" v-else>
- <view class="form-item margin-top">
- <view class="title">
- <text class="necessary">*</text>
- 设备编号:
- </view>
- <input name="deviceCode" v-model="deviceMessage.deviceCode" disabled="disabled"></input>
- </view>
- <view class="form-item">
- <view class="title"><text class="necessary">*</text>设备名称:</view>
- <input name="input" v-model="deviceMessage.deviceName" ></input>
- </view>
- <view class="form-item">
- <view class="title"><text class="necessary">*</text>安装位置:</view>
- <input name="input" v-model="deviceMessage.deviceInstallationPosition"></input>
- </view>
- <view class="form-item">
- <view class="title"><text class="necessary">*</text>所属楼层:</view>
- <select name="" id="" v-model="deviceMessage.floor" filterable clearable>
- <!-- <option value="" >请选择</option> -->
- <option value="-10">楼层B10</option>
- <option value="-9">楼层B9</option>
- <option value="-8">楼层B8</option>
- <option value="-7">楼层B7</option>
- <option value="-6">楼层B6</option>
- <option value="-5">楼层B5</option>
- <option value="-4">楼层B4</option>
- <option value="-3">楼层B3</option>
- <option value="-2">楼层B2</option>
- <option value="-1">楼层B1</option>
- <option :value=index+1 v-for="(item,index) in 60">楼层{{item}}</option>
- </select>
- </view>
- <view class="form-item">
- <view class="title"><text class="necessary">*</text>设备类型:</view>
- <select name="" id="" v-model="deviceMessage.deviceType" filterable clearable>
- <option value="1">智慧用电</option>
- <option value="2">视频监测</option>
- </select>
- </view>
- <view class="form-item">
- <view class="title"><text class="necessary">*</text>站点:</view>
- <select name="" id="" v-model="deviceMessage.siteId" filterable clearable>
- <option :value=item.id v-for="item in siteList">{{ item.siteName}}</option>
- </select>
- </view>
- <view class="btn-area submitBottomBtn padding-lr-sm">
- <button class="bg-blue round margin-top" @click="$noMultipleClicks(editSubmit)">提 交 </button>
- </view>
- </form>
- <!-- 站点修改end -->
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- noClick:true,
-
- siteList: [],
- id: 0,
- deviceCode:'',
- formMess: {
- "deviceCode": "",
- "siteId": "",
- "deviceType": "",
- "deviceName": "",
- "deviceInstallationPosition": "",
- "floor": "",
- },
- deviceMessage: {}
- }
- },
- onLoad: function(option) {
- this.id = option.id
- this.deviceCode=option.deviceCode
- this.getSiteList()
- if (option.deviceCode) {
- uni.setNavigationBarTitle({
- title: '设备修改'
- });
- this.getDeviceList({
- "siteId": option.id,
- "deviceCode": option.deviceCode
- })
- } else {
- uni.setNavigationBarTitle({
- title: '设备新增'
- });
- }
- },
- methods: {
- //新增验证并提交
- addSubmit() {
- if (!this.formMess.deviceCode.replace(/^\s*/g,'')) {
- uni.showToast({
- title: "请填写设备编号",
- icon: "none"
- });
- return
- }
- if (!this.formMess.deviceName.replace(/^\s*/g,'')) {
- uni.showToast({
- title: "请填写设备名称",
- icon: "none"
- });
- return
- }
- if (!this.formMess.deviceInstallationPosition.replace(/^\s*/g,'')) {
- uni.showToast({
- title: "请填写安装位置",
- icon: "none"
- });
- return
- }
- if (!this.formMess.floor) {
- uni.showToast({
- title: "请选择所属楼层",
- icon: "none"
- });
- return
- }
- if (!this.formMess.deviceType) {
- uni.showToast({
- title: "请选择设备类型",
- icon: "none"
- });
- return
- }
- if (!this.formMess.siteId) {
- uni.showToast({
- title: "请选择站点",
- icon: "none"
- });
- return
- }
- this.setAddDevice({
- "deviceCode": this.formMess.deviceCode,
- "siteId": this.formMess.siteId,
- "deviceType": this.formMess.deviceType,
- "deviceName": this.formMess.deviceName,
- "deviceInstallationPosition": this.formMess.deviceInstallationPosition,
- "floor": this.formMess.floor
- })
- },
- //编辑验证并提交
- editSubmit() {
- if (!this.deviceMessage.deviceCode.replace(/^\s*/g,'')) {
- uni.showToast({
- title: "请填写设备编号",
- icon: "none"
- });
- return
- }
- if (!this.deviceMessage.deviceName.replace(/^\s*/g,'')) {
- uni.showToast({
- title: "请填写设备名称",
- icon: "none"
- });
- return
- }
- if (!this.deviceMessage.deviceInstallationPosition.replace(/^\s*/g,'')) {
- uni.showToast({
- title: "请填写安装位置",
- icon: "none"
- });
- return
- }
- if (!this.deviceMessage.floor) {
- uni.showToast({
- title: "请选择所属楼层",
- icon: "none"
- });
- return
- }
- if (!this.deviceMessage.deviceType) {
- uni.showToast({
- title: "请选择设备类型",
- icon: "none"
- });
- return
- }
- if (!this.deviceMessage.siteId) {
- uni.showToast({
- title: "请选择站点",
- icon: "none"
- });
- return
- }
- this.setEditDevice({
- "deviceCode": this.deviceMessage.deviceCode,
- "siteId": this.deviceMessage.siteId,
- "deviceType": this.deviceMessage.deviceType,
- "deviceName": this.deviceMessage.deviceName,
- "deviceInstallationPosition": this.deviceMessage.deviceInstallationPosition,
- "floor": this.deviceMessage.floor
- })
- },
- // 新增请求
- async setAddDevice(ming = {}) {
- const res = await this.$myRequest({
- url: 'DeviceManagement/setAddDevice',
- data: ming
- })
- if (!res.data.flag) {
- uni.showToast({
- title: "添加失败",
- icon: "none"
- });
- } else {
- uni.showToast({
- title: "添加成功",
- });
- }
- setTimeout(() => {
- uni.navigateTo({
- url: '/pages/siteManage/siteManage',
- });
- }, 1000);
- },
- // 站点下拉
- async getSiteList(ming = {}) {
- const res = await this.$myRequest({
- url: 'SiteManagement/getSiteList',
- data: ming
- })
- // this.deviceMessage=res.data.data[0];
- this.siteList = res.data.data
- // console.log(res.data.data)
- },
- // 修改回显请求
- async getDeviceList(ming = {}) {
- const res = await this.$myRequest({
- url: 'DeviceManagement/getDeviceList',
- data: ming
- })
- console.log('res.data.data')
- console.log(res.data.data[0])
- this.deviceMessage = res.data.data[0];
- console.log(this.deviceMessage)
- },
- // 编辑请求
- async setEditDevice(ming = {}) {
- const res = await this.$myRequest({
- url: 'DeviceManagement/setEditDevice',
- data: ming
- })
- if (!res.data.flag) {
- uni.showToast({
- title: "编辑失败",
- icon: "none"
- });
- } else {
- uni.showToast({
- title: "编辑成功",
- });
- }
- setTimeout(() => {
- uni.navigateTo({
- url: '/pages/siteManage/siteManage',
- });
- }, 1000);
- },
- }
- }
- </script>
- <style lang="scss">
- .cu-form-group {
- border-top: 0;
- }
- input,
- select,
- option {
- line-height: 70rpx;
- padding: 0 20rpx;
- height: 70rpx;
- border: 1px solid #EDEDED;
- // width:500rpx!important;
- background-color: #fff;
- box-sizing: border-box;
- appearance: none;
- -moz-appearance: none;
- -webkit-appearance: none;
- color: #999;
- }
- select:focus,
- select:active,
- select:hover {
- outline: none;
- }
- select {
- background: url(../../static/arrow.png) no-repeat scroll 98% center;
- background-size: 6%;
- }
- .form-item label text {
- position: relative;
- top: 2rpx
- }
- .form-item {
- padding: 0 40rpx;
- display: flex;
- align-items: top;
- margin-bottom: 20rpx;
- .title {
- width: 170rpx;
- position: relative;
- .necessary {
- color: red;
- display: inline-block;
- position: absolute;
- top: -2rpx;
- left: -20rpx;
- font-size: 40rpx;
- }
- }
- input,
- select {
- width: 500rpx;
- font-size: 28rpx;
- }
- }
- /* 站点多选下拉样式 start */
- .layui-btn {
- background-color: #5fb878;
- }
- a {
- text-decoration: none;
- }
- .label {
- padding: 2px 0px;
- background: #aaa;
- border-radius: 2px;
- color: #fff;
- display: block;
- line-height: 20px;
- height: 20px;
- margin: 2px 5px 2px 0;
- float: left;
- }
- .label span {
- padding: 0 5px;
- color: #fff;
- }
- .close {
- padding: 1px 5px !important;
- }
- .close:hover {
- /* background-color: #009E94;
- border-radius: 2px;
- color: tomato; */
- }
- .selectId input {
- width: 100% !important;
- }
- .selectId input {
- height: 25px;
- padding: 1px 5px;
- border-radius: 3px;
- width: calc(100% - 12px);
- outline-color: #5fb878;
- border: 1px solid #5fb878;
- }
- .selectId {
- position: relative;
- }
- .selectId dl {
- border: 1px solid #eee;
- border-radius: 3px;
- margin: 2px 0px;
- max-height: 300px;
- overflow-x: hidden;
- white-space: nowrap;
- position: absolute;
- width: 100%;
- top: 40px;
- background: #fff;
- z-index: 1000
- }
- .selectId dl dd {
- margin: 0;
- padding: 5px 10px;
- }
- .selectId dl dd:hover {
- background-color: #5FB878;
- color: white;
- }
- .AD {
- /* width: 210px;
- margin-left: 40px; */
- overflow-y: auto;
- max-height: 200px;
- /* border: 2px solid #5fb878;
- border-radius: 6px;
- padding: 1px 2px; */
- }
- form .AD span {
- width: auto;
- }
- .siteSelect {
- width: 71%;
- display: inline-block;
- }
- /* 站点多选下拉样式end */
- </style>
|