options.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <template>
  2. <view class="page-container" style="position: absolute;left: 0;right: 0;top: 0;bottom: 0">
  3. <view class="option-container uni-column" style="display: flex;">
  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' : ''">
  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. </view>
  21. <view class="uni-row" style="background-color:#ffffff;height: 75%;padding-bottom: 12px;margin-top: 8px;">
  22. <view style="width: 100%;height: 100%;overflow: auto;">
  23. <view v-if="dataList&& dataList.length == 0" style="align-items: center;margin-top: 30px">暂无分选标准数据
  24. </view>
  25. <view v-else v-for="(item, index) in dataList" :key="index"
  26. :class="{'option-item':true,'selectedOptions':isSelectedOptions(item)}" @click="itemClick(item)">
  27. <view class="uni-row">
  28. <view class="value">{{ item.standard }}</view>
  29. <uni-icons v-if="selection.includes(item)" class="arrow-right" type="checkmarkempty"
  30. size="24" />
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="bottom uni-row">
  36. <button class="start-batch-btn" type="primary" :disabled="selection.length ==0"
  37. @click="handleAdd">添加</button>
  38. </view>
  39. </view>
  40. </template>
  41. <script setup>
  42. import {
  43. ref
  44. } from 'vue'
  45. import {
  46. onMounted,
  47. getCurrentInstance
  48. } from 'vue';
  49. import {
  50. onLoad,
  51. onReady,
  52. onUnload,
  53. onShow
  54. } from '@dcloudio/uni-app'
  55. import {
  56. getInstructionInfo
  57. } from '@/api/business/sortDaywork.js'
  58. import {
  59. store
  60. } from '@/store/index.js'
  61. const currentTabName = ref(2)
  62. const keywords = ref('')
  63. const dataList = ref([])
  64. const originalList = ref([])
  65. const selection = ref([])
  66. const dayworkItem = ref(null)
  67. onMounted(() => {
  68. const instance = getCurrentInstance().proxy
  69. const eventChannel = instance.getOpenerEventChannel();
  70. eventChannel.on('acceptDataFromOpenerPage', function(data) {
  71. // console.log('acceptDataFromOpenerPage', data)
  72. // 传入当前报工信息 通过当前报工的产品和工序获取检查指导书和分选标准
  73. if (data && data.data) {
  74. selection.value = []
  75. dayworkItem.value = data.data
  76. console.log(dayworkItem.value)
  77. loadInspection({
  78. technologicalProcessId: dayworkItem.value.technologicalProcessId,
  79. processCode: dayworkItem.value.process.processCode,
  80. lotId: dayworkItem.value.lotId
  81. })
  82. }
  83. })
  84. })
  85. const loadInspection = (data) => {
  86. uni.showLoading({
  87. title: '加载中'
  88. });
  89. // console.log(data)
  90. getInstructionInfo(data).then(res => {
  91. console.log(res)
  92. if (res.code === 200) {
  93. dataList.value = res.data
  94. originalList.value = res.data
  95. uni.hideLoading();
  96. // console.log(optionList1.value, res.data.instructions)
  97. // console.log(optionList2.value, res.data.standards)
  98. } else {
  99. uni.showToast({
  100. icon: 'none',
  101. title: '分选标准获取失败'
  102. })
  103. uni.hideLoading();
  104. }
  105. })
  106. }
  107. function isSelectedOptions(item) {
  108. return selection.value.includes(item);
  109. }
  110. function cateClick(item) {
  111. selectionCategory.value = item
  112. console.log(item)
  113. console.log(categoryList.value)
  114. let index = categoryList.value.findIndex(v => v.id == item.id)
  115. console.log(index)
  116. currentData.value = index
  117. if (categoryList.value[index].instructionList && categoryList.value[index].instructionList.length > 0) {
  118. dataList.value = categoryList.value[index].instructionList
  119. originalList.value = categoryList.value[index].instructionList
  120. } else {
  121. dataList.value = []
  122. }
  123. }
  124. function itemClick(item) {
  125. const buttonIndex = selection.value.findIndex(selectedItem => selectedItem === item);
  126. if (buttonIndex > -1) {
  127. selection.value.splice(buttonIndex, 1); // 取消选中
  128. } else {
  129. selection.value.push(item); // 选中
  130. }
  131. }
  132. function handleSearch() {
  133. if (keywords.value == "") {
  134. dataList.value = originalList.value
  135. } else {
  136. dataList.value = originalList.value.filter(item => item.standard.includes(keywords.value))
  137. }
  138. }
  139. // 页面生命周期函数
  140. onLoad(() => {
  141. })
  142. // tabbar切换
  143. function handleAdd() {
  144. console.log(selection.value)
  145. uni.$emit('addUnfitInfoEvent',
  146. selection.value
  147. )
  148. uni.navigateBack()
  149. }
  150. </script>
  151. <style lang="scss">
  152. .selected {
  153. border-left: 5px solid #c0c4fc;
  154. font-weight: 700;
  155. /* 选中之后样式 */
  156. }
  157. .page-container {
  158. background-color: #ececec;
  159. font-size: 28rpx;
  160. padding: 24rpx;
  161. box-sizing: border-box;
  162. }
  163. .option-container {
  164. height: 10%;
  165. background-color: #ffffff;
  166. padding: 24rpx;
  167. border-radius: 12rpx;
  168. }
  169. .tab-bars {
  170. height: 56rpx;
  171. >view {
  172. flex: 1;
  173. text-align: center;
  174. .line {
  175. width: 50%;
  176. height: 2px;
  177. margin: 8rpx auto 0 auto;
  178. background-color: #FFFFFF;
  179. }
  180. &.active {
  181. .line {
  182. background-color: #1684FC;
  183. }
  184. }
  185. }
  186. }
  187. .search-container {
  188. margin-top: 16rpx;
  189. align-items: center;
  190. input {
  191. flex: 1;
  192. height: 72rpx;
  193. border: 1px solid #bbbbbb;
  194. padding: 0 8rpx;
  195. box-sizing: border-box;
  196. }
  197. .btn {
  198. display: flex;
  199. flex-direction: row;
  200. width: 112rpx;
  201. height: 72rpx;
  202. align-items: center;
  203. justify-content: center;
  204. background-color: #1684FC;
  205. color: #ffffff;
  206. }
  207. }
  208. .option-item {
  209. position: relative;
  210. margin-top: 24rpx;
  211. padding-bottom: 8rpx;
  212. border-bottom: 1px solid #BBBBBB;
  213. margin-left: 24rpx;
  214. .uni-row {
  215. padding-bottom: 16rpx;
  216. .label {
  217. width: 144rpx;
  218. }
  219. .value {
  220. flex: 1;
  221. }
  222. }
  223. .uni-row:first-child {
  224. font-size: 32rpx;
  225. }
  226. .arrow-right {
  227. position: absolute;
  228. right: 24rpx;
  229. }
  230. }
  231. .uniui-checkmarkempty[data-v-d31e1c47]:before {
  232. color: #1684FC;
  233. }
  234. .selectedOptions {
  235. color: #1684FC;
  236. }
  237. .bottom {
  238. height: 10%;
  239. position: fixed;
  240. right: 0;
  241. bottom: 0;
  242. left: 0;
  243. height: 100rpx;
  244. border-top: 1px solid #999999;
  245. padding: 16rpx 32rpx;
  246. align-items: center;
  247. background-color: #fff;
  248. justify-content: space-evenly;
  249. .start-batch-btn {
  250. flex: 1;
  251. height: 80rpx;
  252. line-height: 80rpx;
  253. border-radius: 8rpx;
  254. color: #FFFFFF;
  255. font-size: 28rpx;
  256. }
  257. }
  258. </style>