Files
hht-zzzw-uni/pages/zw/point-attrset.vue
2025-09-16 10:13:01 +08:00

183 lines
4.4 KiB
Vue

<template>
<view class="zd_container">
<!-- 点位属性设置 -->
<nav-bar :title="title"></nav-bar>
<view class="zd_content">
<view class="zd_wrapper">
<view class="zd-row border-bottom">
<view class="zd-col-7">
<span class="filter_label">点位</span>
</view>
<view class="zd-col-17">
<search-box
v-model="val1"
@handleChange="handleChange"
/>
</view>
</view>
<!-- <view class="zd-row border-bottom">
<view class="zd-col-7">
<span class="filter_label">点位属性</span>
</view>
<view class="zd-col-24 filter_select">
<uni-data-select v-model="index" :localdata="options" @change="selectChange"></uni-data-select>
</view>
</view> -->
<view class="zd_wrapper grid-wraper">
<view class="slide_new">
<table>
<thead>
<tr>
<th>点位</th>
<th>属性</th>
</tr>
</thead>
<tbody>
<tr v-for="(item, i) in dataList" :key="i">
<td>{{item.point_code}}</td>
<td><span class="span1" :class="{'hightlight': item.point_type === '1'}" @tap="setpoint_type(item, '1')">入库点</span><span class="span1" :class="{'hightlight': item.point_type === '2'}" @tap="setpoint_type(item, '2')">出库点</span></td>
<!-- <uni-data-select
v-model="item.point_type"
:localdata="options"
@change="handleTypeChange(item, $event)">
</uni-data-select> -->
</tr>
</tbody>
</table>
</view>
</view>
</view>
</view>
<view class="zd-row submit-bar">
<button class="zd-col-7 button-default" @tap="clearUp">清空</button>
<button class="zd-col-7 button-primary" @tap="seachList">查询</button>
<button class="zd-col-8 button-primary" :class="{'button-info': !dataList.length}" :disabled="disabled" @tap="_updatePointType">确认</button>
</view>
</view>
</template>
<script>
import NavBar from '@/components/NavBar.vue'
import SearchBox from '@/components/SearchBox.vue'
import {getInBillPointList, updatePointType} from '@/utils/getData4.js'
export default {
components: {
NavBar,
SearchBox
},
data() {
return {
title: '',
val1: '',
options: [{text:'入库点', value:'1'},{text:'出库点',value: '2'}],
index: '',
dataList: [],
// dataList: [
// { point_code: 'P-1001', point_type: '2' },
// { point_code: 'P-1002', point_type: '1' },
// { point_code: 'P-1003', point_type: '2' },
// { point_code: 'P-1004', point_type: '2' }
// ],
disabled: false
};
},
onLoad (options) {
this.title = options.title
},
created () {
this.seachList()
},
methods: {
handleChange (e) {
if (e) {
this.seachList()
}
},
seachList () {
this.dataList = []
this._getInBillPointList()
},
handleTypeChange (e, item) {
console.log(item, 666)
console.log(e, 222)
this.dataList.map((el) => {
if (el === e) {
el.point_type = e.point_type
}
})
},
selectChange (e) {
this.index = e
},
clearUp () {
this.val1 = ''
this.dataList = []
this.disabled = false
},
setpoint_type(item, type) {
// 如果已经是当前类型,则不执行操作
if (item.point_type === type) return;
// 更新UI
item.point_type = type;
this.dataList.map((el) => {
if (el === item) {
el.point_type = type
}
})
},
async _getInBillPointList () {
let res = await getInBillPointList(this.val1)
if (res.code === '200') {
this.dataList = res.data
}
},
async _updatePointType () {
this.disabled = true
if (!this.dataList.length) {
this.disabled = false
return
}
try {
let res = await updatePointType(this.dataList)
if (res.code === '200') {
uni.showToast({
title: res.message,
icon: 'none'
})
this.clearUp()
} else {
uni.showToast({
title: res.message,
icon: 'none'
})
this.disabled = false
}
} catch (e) {
this.disabled = false
}
}
}
}
</script>
<style lang="stylus">
.slide_new table td {
font-size: 17px;
line-height: 62px;
color: #323232;
text-align: center;
box-sizing: border-box;
overflow: none;
white-space: none;
text-overflow: none;
white-space: none;
padding: 0 12px;
background: #fff;
}
.span1
display inline-block
width 50%
.hightlight
color orange
</style>