options.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <template>
  2. <view class="page-container uni-column">
  3. <view class="option-container uni-column">
  4. <!-- tab-bar -->
  5. <view class="tab-bars uni-row">
  6. <view :class="currentTabName === 1 ? 'active' : ''" @click.stop="handleTabBarClick(1)">
  7. <text>检查指导书</text>
  8. <view class="line"></view>
  9. </view>
  10. <view :class="currentTabName === 2 ? 'active' : ''" @click.stop="handleTabBarClick(2)">
  11. <text>分选标准</text>
  12. <view class="line"></view>
  13. </view>
  14. </view>
  15. <!-- 搜索框 -->
  16. <view class="search-container uni-row">
  17. <input type="text" v-model="keywords" placeholder="请输入编号/关键字" />
  18. <view class="btn">搜索</view>
  19. </view>
  20. <!-- 选项 -->
  21. <view class="option-item" v-for="(item, index) in optionList" :key="index"
  22. @click="handleOptionChecked(item)">
  23. <view class="uni-row">
  24. <view class="label">检查项</view>
  25. <view class="value">{{ item.title }}</view>
  26. </view>
  27. <view class="uni-row">
  28. <view class="label">检查标准</view>
  29. <view class="value">{{ item.standard }}</view>
  30. </view>
  31. <uni-icons class="arrow-right" type="right" size="24" />
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. <script setup>
  37. import {
  38. ref
  39. } from 'vue'
  40. import {
  41. onMounted,
  42. getCurrentInstance
  43. } from 'vue';
  44. import {
  45. onLoad,
  46. onReady,
  47. onUnload,
  48. onShow
  49. } from '@dcloudio/uni-app'
  50. import {
  51. getInspectionList
  52. } from '@/api/business/sortDaywork.js'
  53. const currentTabName = ref(1)
  54. const keywords = ref('')
  55. const optionList = ref([])
  56. // 检查指导书
  57. const optionList1 = ref([])
  58. // 分选标准
  59. const optionList2 = ref([])
  60. const dayworkItem = ref({})
  61. onMounted(() => {
  62. const instance = getCurrentInstance().proxy
  63. const eventChannel = instance.getOpenerEventChannel();
  64. eventChannel.on('acceptDataFromOpenerPage', function(data) {
  65. // console.log('acceptDataFromOpenerPage', data)
  66. // 传入当前报工信息 通过当前报工的产品和工序获取检查指导书和分选标准
  67. if (data && data.data) {
  68. dayworkItem.value = data.data
  69. loadInspection({
  70. technologicalProcessId: dayworkItem.value.technologicalProcessId,
  71. processId: dayworkItem.value.processId
  72. })
  73. }
  74. })
  75. })
  76. // 页面生命周期函数
  77. onLoad(() => {
  78. // optionList1.value = [
  79. // {
  80. // title: '001 台阶径',
  81. // standard: '角偏 < 0.05'
  82. // },
  83. // {
  84. // title: '002 台阶径',
  85. // standard: '角偏 < 0.04'
  86. // }
  87. // ]
  88. // optionList2.value = [
  89. // {
  90. // title: '划痕',
  91. // standard: '划痕描述'
  92. // },
  93. // {
  94. // title: '划伤',
  95. // standard: '划伤描述'
  96. // }
  97. // ]
  98. // optionList.value = optionList1.value
  99. })
  100. const loadInspection = (data) => {
  101. // console.log(data)
  102. getInspectionList(data).then(res => {
  103. console.log(res)
  104. if (res.code === 200) {
  105. optionList1.value = res.data.instructions
  106. optionList2.value = res.data.standards
  107. handleTabBarClick(currentTabName.value)
  108. // console.log(optionList1.value, res.data.instructions)
  109. // console.log(optionList2.value, res.data.standards)
  110. } else {
  111. uni.showToast({
  112. icon: 'none',
  113. title: '分选标准和检查指导项获取失败'
  114. })
  115. }
  116. })
  117. }
  118. // tabbar切换
  119. const handleTabBarClick = (val) => {
  120. switch (val) {
  121. case 1:
  122. optionList.value = optionList1.value
  123. break
  124. case 2:
  125. optionList.value = optionList2.value
  126. }
  127. currentTabName.value = val
  128. }
  129. const handleOptionChecked = (data) => {
  130. uni.$emit('addUnfitInfoEvent', {
  131. id: data.id,
  132. title: data.title,
  133. standard: data.standard,
  134. type: data.type
  135. })
  136. uni.navigateBack()
  137. }
  138. </script>
  139. <style lang="scss">
  140. .page-container {
  141. height: 100%;
  142. background-color: #ececec;
  143. font-size: 28rpx;
  144. padding: 24rpx;
  145. box-sizing: border-box;
  146. }
  147. .option-container {
  148. background-color: #ffffff;
  149. padding: 24rpx;
  150. border-radius: 12rpx;
  151. }
  152. .tab-bars {
  153. height: 56rpx;
  154. >view {
  155. flex: 1;
  156. text-align: center;
  157. .line {
  158. width: 50%;
  159. height: 2px;
  160. margin: 8rpx auto 0 auto;
  161. background-color: #FFFFFF;
  162. }
  163. &.active {
  164. .line {
  165. background-color: #1684FC;
  166. }
  167. }
  168. }
  169. }
  170. .search-container {
  171. margin-top: 16rpx;
  172. align-items: center;
  173. input {
  174. flex: 1;
  175. height: 72rpx;
  176. border: 1px solid #bbbbbb;
  177. padding: 0 8rpx;
  178. box-sizing: border-box;
  179. }
  180. .btn {
  181. display: flex;
  182. flex-direction: row;
  183. width: 112rpx;
  184. height: 72rpx;
  185. align-items: center;
  186. justify-content: center;
  187. background-color: #1684FC;
  188. color: #ffffff;
  189. }
  190. }
  191. .option-item {
  192. position: relative;
  193. margin-top: 24rpx;
  194. padding-bottom: 8rpx;
  195. border-bottom: 1px solid #BBBBBB;
  196. .uni-row {
  197. padding-bottom: 16rpx;
  198. .label {
  199. width: 144rpx;
  200. }
  201. .value {
  202. flex: 1;
  203. }
  204. }
  205. .uni-row:first-child {
  206. font-size: 32rpx;
  207. font-weight: 700;
  208. }
  209. .arrow-right {
  210. position: absolute;
  211. top: 24rpx;
  212. right: 24rpx;
  213. }
  214. }
  215. </style>