Files
hht-tongbo-two/pages/SecondPhase/slitting/Zjpindan.vue
2025-09-02 18:02:26 +08:00

115 lines
3.0 KiB
Vue

<template>
<view class="zd_container">
<!-- <nav-bar title="子卷拼单"></nav-bar> -->
<nav-bar :title="title"></nav-bar>
<view class="zd_content">
<view class="zd_wrapper">
<view class="filter_item">
<view class="filter_label">区域</view>
<view class="filter_input_wraper">
<uni-data-select v-model="index" :localdata="options" @change="selectChange"></uni-data-select>
</view>
</view>
</view>
<view class="zd_wrapper grid-wraper">
<view class="slide_new">
<table>
<thead>
<tr>
<!-- <th @tap="toAllCheck"><uni-icons :type="allCheck ? 'checkbox' : 'circle'" size="24" color="#4e6ef2"></uni-icons></th> -->
<th>选择</th>
<th>点位编码</th>
</tr>
</thead>
<tbody>
<tr v-for="(e, i) in dataList" :key="i">
<td @tap="toCheck(e)"><uni-icons :type="e.checked ? 'checkbox' : 'circle'" size="24" color="#4e6ef2"></uni-icons></td>
<td>{{e.point_code}}</td>
</tr>
</tbody>
</table>
</view>
</view>
</view>
<view class="zd-row submitbar">
<button class="zd-col-22 btn-submit btn-success" :class="{'btn-info': checkedArr.length !== 2}" :disabled="disabled" @tap="_conCombination">拼单</button>
</view>
</view>
</template>
<script>
import NavBar from '@/components/NavBar.vue'
import SearchBox from '@/components/SearchBox.vue'
import {getConmbinationlnfo, conCombination} from '@/utils/getData3.js'
export default {
components: {
NavBar,
SearchBox
},
data() {
return {
title: '',
options: [{text:'B1', value:'B1'}, {text:'B2', value: 'B2'}],
index: '',
dataList: [],
// dataList: [{point_code: 'c001'}, {point_code: 'c002'}, {point_code: 'c003'}, {point_code: 'c004'}],
allCheck: false,
checkedArr: [],
disabled: false
};
},
onLoad (options) {
this.title = options.title
},
created () {
},
methods: {
async _getConmbinationlnfo () {
let res = await getConmbinationlnfo(this.index)
this.dataList = res.data
this.dataList.map(el => {
this.$set(el, 'checked', false)
})
},
selectChange (e) {
if (e) {
this.index = e
this._getConmbinationlnfo()
}
},
toAllCheck () {
this.allCheck = !this.allCheck
this.dataList.map(el => {
el.checked = this.allCheck
})
},
toCheck (e) {
e.checked = !e.checked
this.checkedArr = this.dataList.filter(el => el.checked === true)
this.allCheck = this.checkedArr.length === this.dataList.length
},
async _conCombination () {
this.disabled = true
if (this.checkedArr.length !== 2) {
uni.showToast({
title: '请选择两条数据',
icon: 'none'
})
this.disabled = false
return
}
try {
let res = await conCombination(this.checkedArr)
uni.showToast({
title: res.message,
icon: 'none'
})
this.index = ''
this.disabled = false
} catch (e) {
this.disabled = false
}
}
}
}
</script>