options.vue 6.8 KB

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