options.vue 6.6 KB

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