options.vue 6.7 KB

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