123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315 |
- <template>
- <view class="page-container" style="position: absolute;left: 0;right: 0;top: 0;bottom: 0">
- <view class="option-container uni-column" style="display: flex;">
- <!-- tab-bar -->
- <view class="tab-bars uni-row">
- <!-- <view :class="currentTabName === 1 ? 'active' : ''" @click.stop="handleTabBarClick(1)">
- <text>检查指导书</text>
- <view class="line"></view>
- </view> -->
- <view :class="currentTabName === 2 ? 'active' : ''">
- <text>分选标准</text>
- <view class="line"></view>
- </view>
- </view>
- <!-- 搜索框 -->
- <view class="search-container uni-row">
- <input type="text" v-model="keywords" placeholder="请输入关键字" />
- <view class="btn" @click="handleSearch()">搜索</view>
- </view>
- </view>
- <view class="uni-row" style="position: absolute;
- background-color: rgb(255, 255, 255);
- height: 68%;
- margin-top: 20px;
- top:102px;
- left: 12px;
- right: 12px;">
- <view style="width: 100%;height: 100%;overflow: auto;">
- <view v-if="dataList&& dataList.length == 0" style="align-items: center;margin-top: 30px">暂无分选标准数据
- </view>
- <view v-else v-for="(item, index) in dataList" :key="index"
- :class="{'option-item':true,'selectedOptions':isSelectedOptions(item)}" @click="itemClick(item)">
- <view class="uni-row">
- <view class="value">{{ item.standard }}</view>
- <uni-icons v-if="selection.includes(item)" class="arrow-right" type="checkmarkempty"
- size="24" />
- </view>
- </view>
- </view>
- </view>
- <view class="bottom uni-row">
- <button class="start-batch-btn" type="primary" :disabled="selection.length ==0"
- @click="handleAdd">添加</button>
- </view>
- </view>
- </template>
- <script setup>
- import {
- ref
- } from 'vue'
- import {
- onMounted,
- getCurrentInstance
- } from 'vue';
- import {
- onLoad,
- onReady,
- onUnload,
- onShow
- } from '@dcloudio/uni-app'
- import {
- getInstructionInfo
- } from '@/api/business/sortDaywork.js'
- import {
- store
- } from '@/store/index.js'
- const currentTabName = ref(2)
- const keywords = ref('')
- const dataList = ref([])
- const originalList = ref([])
- const selection = ref([])
- const dayworkItem = ref(null)
- onMounted(() => {
- const instance = getCurrentInstance().proxy
- const eventChannel = instance.getOpenerEventChannel();
- eventChannel.on('acceptDataFromOpenerPage', function(data) {
- // console.log('acceptDataFromOpenerPage', data)
- // 传入当前报工信息 通过当前报工的产品和工序获取检查指导书和分选标准
- if (data && data.data) {
- selection.value = []
- dayworkItem.value = data.data
- console.log(dayworkItem.value)
- loadInspection({
- technologicalProcessId: dayworkItem.value.technologicalProcessId,
- processCode: dayworkItem.value.process.processCode,
- lotId: dayworkItem.value.lotId
- })
- }
- })
- })
- const loadInspection = (data) => {
- uni.showLoading({
- title: '加载中'
- });
- // console.log(data)
- getInstructionInfo(data).then(res => {
- console.log(res)
- if (res.code === 200) {
- dataList.value = res.data
- originalList.value = res.data
- uni.hideLoading();
- // console.log(optionList1.value, res.data.instructions)
- // console.log(optionList2.value, res.data.standards)
- } else {
- uni.showToast({
- icon: 'none',
- title: '分选标准获取失败'
- })
- uni.hideLoading();
- }
- })
- }
- function isSelectedOptions(item) {
- return selection.value.includes(item);
- }
- function cateClick(item) {
- selectionCategory.value = item
- console.log(item)
- console.log(categoryList.value)
- let index = categoryList.value.findIndex(v => v.id == item.id)
- console.log(index)
- currentData.value = index
- if (categoryList.value[index].instructionList && categoryList.value[index].instructionList.length > 0) {
- dataList.value = categoryList.value[index].instructionList
- originalList.value = categoryList.value[index].instructionList
- } else {
- dataList.value = []
- }
- }
- function itemClick(item) {
- const buttonIndex = selection.value.findIndex(selectedItem => selectedItem === item);
- if (buttonIndex > -1) {
- selection.value.splice(buttonIndex, 1); // 取消选中
- } else {
- selection.value.push(item); // 选中
- }
- }
- function handleSearch() {
- if (keywords.value == "") {
- dataList.value = originalList.value
- } else {
- dataList.value = originalList.value.filter(item => item.standard.includes(keywords.value))
- }
- }
- // 页面生命周期函数
- onLoad(() => {
- })
- // tabbar切换
- function handleAdd() {
- console.log(selection.value)
- uni.$emit('addUnfitInfoEvent',
- selection.value
- )
- uni.navigateBack()
- }
- </script>
- <style lang="scss">
- .selected {
- border-left: 5px solid #c0c4fc;
- font-weight: 700;
- /* 选中之后样式 */
- }
- .page-container {
- background-color: #ececec;
- font-size: 28rpx;
- padding: 24rpx;
- box-sizing: border-box;
- }
- .option-container {
- // height: 13%;
- // height: 120px;
- // background-color: #ffffff;
- // padding: 24rpx;
- // border-radius: 12rpx;
- position: fixed;
- top: 50px;
- /* height: 13%; */
- background-color: #fff;
- padding: .75rem;
- border-radius: .375rem;
- left: 12px;
- right: 12px;
- height: 80px;
- z-index: 5;
- }
- .tab-bars {
- height: 56rpx;
- >view {
- flex: 1;
- text-align: center;
- .line {
- width: 50%;
- height: 2px;
- margin: 8rpx auto 0 auto;
- background-color: #FFFFFF;
- }
- &.active {
- .line {
- background-color: #1684FC;
- }
- }
- }
- }
- .search-container {
- margin-top: 16rpx;
- align-items: center;
- input {
- flex: 1;
- height: 72rpx;
- border: 1px solid #bbbbbb;
- padding: 0 8rpx;
- box-sizing: border-box;
- }
- .btn {
- display: flex;
- flex-direction: row;
- width: 112rpx;
- height: 72rpx;
- align-items: center;
- justify-content: center;
- background-color: #1684FC;
- color: #ffffff;
- }
- }
- .option-item {
- position: relative;
- margin-top: 24rpx;
- padding-bottom: 8rpx;
- border-bottom: 1px solid #BBBBBB;
- margin-left: 24rpx;
- .uni-row {
- padding-bottom: 16rpx;
- .label {
- width: 144rpx;
- }
- .value {
- flex: 1;
- }
- }
- .uni-row:first-child {
- font-size: 32rpx;
- }
- .arrow-right {
- position: absolute;
- right: 24rpx;
- }
- }
- .uniui-checkmarkempty[data-v-d31e1c47]:before {
- color: #1684FC;
- }
- .selectedOptions {
- color: #1684FC;
- }
- .bottom {
- height: 10%;
- position: fixed;
- right: 0;
- bottom: 0;
- left: 0;
- height: 100rpx;
- border-top: 1px solid #999999;
- padding: 16rpx 32rpx;
- align-items: center;
- background-color: #fff;
- justify-content: space-evenly;
- .start-batch-btn {
- flex: 1;
- height: 80rpx;
- line-height: 80rpx;
- border-radius: 8rpx;
- color: #FFFFFF;
- font-size: 28rpx;
- }
- }
- </style>
|