options.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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" @click="handleSearch()">搜索</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. const index = ref(0)
  62. onMounted(() => {
  63. const instance = getCurrentInstance().proxy
  64. const eventChannel = instance.getOpenerEventChannel();
  65. eventChannel.on('acceptDataFromOpenerPage', function(data) {
  66. // console.log('acceptDataFromOpenerPage', data)
  67. // 传入当前报工信息 通过当前报工的产品和工序获取检查指导书和分选标准
  68. if (data && data.data) {
  69. dayworkItem.value = data.data
  70. index.value = data.index
  71. loadInspection({
  72. technologicalProcessId: dayworkItem.value.technologicalProcessId,
  73. processId: dayworkItem.value.processId
  74. })
  75. }
  76. })
  77. })
  78. function handleSearch() {
  79. let data = {technologicalProcessId: dayworkItem.value.technologicalProcessId,
  80. processId: dayworkItem.value.processId,
  81. keywords:keywords.value}
  82. getInspectionList(data).then(res => {
  83. console.log(res)
  84. if (res.code === 200) {
  85. optionList1.value = res.data.instructions
  86. optionList2.value = res.data.standards
  87. if(currentTabName.value == 1){
  88. optionList.value = optionList1.value
  89. }else{
  90. optionList.value = optionList2.value
  91. }
  92. } else {
  93. uni.showToast({
  94. icon: 'none',
  95. title: '分选标准和检查指导项获取失败'
  96. })
  97. }
  98. })
  99. }
  100. // 页面生命周期函数
  101. onLoad(() => {
  102. // optionList1.value = [
  103. // {
  104. // title: '001 台阶径',
  105. // standard: '角偏 < 0.05'
  106. // },
  107. // {
  108. // title: '002 台阶径',
  109. // standard: '角偏 < 0.04'
  110. // }
  111. // ]
  112. // optionList2.value = [
  113. // {
  114. // title: '划痕',
  115. // standard: '划痕描述'
  116. // },
  117. // {
  118. // title: '划伤',
  119. // standard: '划伤描述'
  120. // }
  121. // ]
  122. // optionList.value = optionList1.value
  123. })
  124. const loadInspection = (data) => {
  125. // console.log(data)
  126. getInspectionList(data).then(res => {
  127. console.log(res)
  128. if (res.code === 200) {
  129. optionList1.value = res.data.instructions
  130. optionList2.value = res.data.standards
  131. handleTabBarClick(currentTabName.value)
  132. // console.log(optionList1.value, res.data.instructions)
  133. // console.log(optionList2.value, res.data.standards)
  134. } else {
  135. uni.showToast({
  136. icon: 'none',
  137. title: '分选标准和检查指导项获取失败'
  138. })
  139. }
  140. })
  141. }
  142. // tabbar切换
  143. const handleTabBarClick = (val) => {
  144. let data = {technologicalProcessId: dayworkItem.value.technologicalProcessId,
  145. processId: dayworkItem.value.processId,
  146. keywords:keywords.value}
  147. getInspectionList(data).then(res => {
  148. console.log(res)
  149. if (res.code === 200) {
  150. optionList1.value = res.data.instructions
  151. optionList2.value = res.data.standards
  152. } else {
  153. uni.showToast({
  154. icon: 'none',
  155. title: '分选标准和检查指导项获取失败'
  156. })
  157. }
  158. })
  159. switch (val) {
  160. case 1:
  161. optionList.value = optionList1.value
  162. keywords.value =''
  163. break
  164. case 2:
  165. optionList.value = optionList2.value
  166. keywords.value = ''
  167. }
  168. currentTabName.value = val
  169. }
  170. const handleOptionChecked = (data) => {
  171. uni.$emit('addUnfitInfoEvent', {
  172. id: data.id,
  173. title: data.title,
  174. standard: data.standard,
  175. type: data.type,
  176. index: index.value + 1
  177. })
  178. uni.navigateBack()
  179. }
  180. </script>
  181. <style lang="scss">
  182. .page-container {
  183. height: 100%;
  184. background-color: #ececec;
  185. font-size: 28rpx;
  186. padding: 24rpx;
  187. box-sizing: border-box;
  188. }
  189. .option-container {
  190. background-color: #ffffff;
  191. padding: 24rpx;
  192. border-radius: 12rpx;
  193. }
  194. .tab-bars {
  195. height: 56rpx;
  196. >view {
  197. flex: 1;
  198. text-align: center;
  199. .line {
  200. width: 50%;
  201. height: 2px;
  202. margin: 8rpx auto 0 auto;
  203. background-color: #FFFFFF;
  204. }
  205. &.active {
  206. .line {
  207. background-color: #1684FC;
  208. }
  209. }
  210. }
  211. }
  212. .search-container {
  213. margin-top: 16rpx;
  214. align-items: center;
  215. input {
  216. flex: 1;
  217. height: 72rpx;
  218. border: 1px solid #bbbbbb;
  219. padding: 0 8rpx;
  220. box-sizing: border-box;
  221. }
  222. .btn {
  223. display: flex;
  224. flex-direction: row;
  225. width: 112rpx;
  226. height: 72rpx;
  227. align-items: center;
  228. justify-content: center;
  229. background-color: #1684FC;
  230. color: #ffffff;
  231. }
  232. }
  233. .option-item {
  234. position: relative;
  235. margin-top: 24rpx;
  236. padding-bottom: 8rpx;
  237. border-bottom: 1px solid #BBBBBB;
  238. .uni-row {
  239. padding-bottom: 16rpx;
  240. .label {
  241. width: 144rpx;
  242. }
  243. .value {
  244. flex: 1;
  245. }
  246. }
  247. .uni-row:first-child {
  248. font-size: 32rpx;
  249. font-weight: 700;
  250. }
  251. .arrow-right {
  252. position: absolute;
  253. top: 24rpx;
  254. right: 24rpx;
  255. }
  256. }
  257. </style>