specialOptions.vue 7.0 KB

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