specialOptions.vue 6.9 KB

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