specialOptions.vue 7.4 KB

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