specialOptions.vue 7.4 KB

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