123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310 |
- <template>
- <view class="page-container uni-column">
- <view class="option-container uni-column">
- <!-- 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' : ''" @click.stop="handleTabBarClick(2)">
- <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 class="option-item" v-for="(item, index) in optionList" :key="index"
- @click="handleOptionChecked(item)">
- <view class="uni-row">
- <view class="label">检查项</view>
- <view class="value">{{ item.title }}</view>
- </view>
- <view class="uni-row">
- <view class="label">检查标准</view>
- <view class="value">{{ item.standard }}</view>
- </view>
- <uni-icons class="arrow-right" type="right" size="24" />
- </view>
- </view>
- </view>
- </template>
- <script setup>
- import {
- ref
- } from 'vue'
- import {
- onMounted,
- getCurrentInstance
- } from 'vue';
- import {
- onLoad,
- onReady,
- onUnload,
- onShow
- } from '@dcloudio/uni-app'
- import {
- getInspectionList
- } from '@/api/business/sortDaywork.js'
- const currentTabName = ref(1)
- const keywords = ref('')
- const optionList = ref([])
- // 检查指导书
- const optionList1 = ref([])
- // 分选标准
- const optionList2 = ref([])
- const dayworkItem = ref({})
- const index = ref(0)
- onMounted(() => {
- const instance = getCurrentInstance().proxy
- const eventChannel = instance.getOpenerEventChannel();
- eventChannel.on('acceptDataFromOpenerPage', function(data) {
- // console.log('acceptDataFromOpenerPage', data)
- // 传入当前报工信息 通过当前报工的产品和工序获取检查指导书和分选标准
- if (data && data.data) {
- dayworkItem.value = data.data
- console.log(dayworkItem.value)
- index.value = data.index
- loadInspection({
- technologicalProcessId: dayworkItem.value.technologicalProcessId,
- processId: dayworkItem.value.processId,
- lotId: dayworkItem.value.lotId
- })
- }
- })
- })
- function handleSearch() {
- console.log(dayworkItem.value)
- let data = {
- technologicalProcessId: dayworkItem.value.technologicalProcessId,
- processId: dayworkItem.value.processId,
- keywords: keywords.value,
- lotId: dayworkItem.value.lotId
- }
- getInspectionList(data).then(res => {
- console.log(res)
- if (res.code === 200) {
- optionList1.value = res.data.instructions
- optionList2.value = res.data.standards
- if (currentTabName.value == 1) {
- optionList.value = optionList1.value
- } else {
- optionList.value = optionList2.value
- }
- } else {
- uni.showToast({
- icon: 'none',
- title: '分选标准和检查指导项获取失败'
- })
- }
- })
- }
- // 页面生命周期函数
- onLoad(() => {
- // optionList1.value = [
- // {
- // title: '001 台阶径',
- // standard: '角偏 < 0.05'
- // },
- // {
- // title: '002 台阶径',
- // standard: '角偏 < 0.04'
- // }
- // ]
- // optionList2.value = [
- // {
- // title: '划痕',
- // standard: '划痕描述'
- // },
- // {
- // title: '划伤',
- // standard: '划伤描述'
- // }
- // ]
- // optionList.value = optionList1.value
- })
- const loadInspection = (data) => {
- // console.log(data)
- getInspectionList(data).then(res => {
- console.log(res)
- if (res.code === 200) {
- optionList1.value = res.data.instructions
- optionList2.value = res.data.standards
- //handleTabBarClick(currentTabName.value)
- currentTabName.value = 1
- optionList.value = optionList1.value
- // console.log(optionList1.value, res.data.instructions)
- // console.log(optionList2.value, res.data.standards)
- } else {
- uni.showToast({
- icon: 'none',
- title: '分选标准和检查指导项获取失败'
- })
- }
- })
- }
- // tabbar切换
- const handleTabBarClick = (val) => {
- switch (val) {
- case 1:
- keywords.value = ''
- var data = {
- technologicalProcessId: dayworkItem.value.technologicalProcessId,
- processId: dayworkItem.value.processId,
- lotId: dayworkItem.value.lotId
- }
- getInspectionList(data).then(res => {
- console.log(res)
- if (res.code === 200) {
- optionList1.value = res.data.instructions
- optionList2.value = res.data.standards
- optionList.value = optionList1.value
- } else {
- uni.showToast({
- icon: 'none',
- title: '检查指导项获取失败'
- })
- }
- })
- break
- case 2:
- keywords.value = ''
- var data = {
- technologicalProcessId: dayworkItem.value.technologicalProcessId,
- processId: dayworkItem.value.processId,
- lotId: dayworkItem.value.lotId
- }
- getInspectionList(data).then(res => {
- console.log(res)
- if (res.code === 200) {
- optionList1.value = res.data.instructions
- optionList2.value = res.data.standards
- optionList.value = optionList2.value
- } else {
- uni.showToast({
- icon: 'none',
- title: '分选标准获取失败'
- })
- }
- })
- }
- currentTabName.value = val
- console.log(optionList.value)
- }
- const handleOptionChecked = (data) => {
- uni.$emit('addUnfitInfoEvent', {
- id: data.id,
- title: data.title,
- standard: data.standard,
- type: data.type,
- index: index.value + 1
- })
- uni.navigateBack()
- }
- </script>
- <style lang="scss">
- .page-container {
- height: 100%;
- background-color: #ececec;
- font-size: 28rpx;
- padding: 24rpx;
- box-sizing: border-box;
- }
- .option-container {
- background-color: #ffffff;
- padding: 24rpx;
- border-radius: 12rpx;
- }
- .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;
- .uni-row {
- padding-bottom: 16rpx;
- .label {
- width: 144rpx;
- }
- .value {
- flex: 1;
- }
- }
- .uni-row:first-child {
- font-size: 32rpx;
- font-weight: 700;
- }
- .arrow-right {
- position: absolute;
- top: 24rpx;
- right: 24rpx;
- }
- }
- </style>
|