show.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. <template>
  2. <view>
  3. <view v-if="!isCreate">
  4. <uni-section title="">
  5. <view class="example">
  6. <uni-forms ref="form" :modelValue="item" labelWidth="80px" :rules="rules">
  7. <uni-forms-item label="装箱单号" name="FBillNo">
  8. <uni-easyinput v-model="item['FENCHASENUM.LT']" disabled>
  9. </uni-easyinput>
  10. </uni-forms-item>
  11. <uni-forms-item label="调拨数量" name="FQty">
  12. <uni-easyinput v-model="item['FQty']" />
  13. </uni-forms-item>
  14. </uni-forms>
  15. <button type="primary" @click="submit()">确认</button>
  16. </view>
  17. </uni-section>
  18. </view>
  19. <view class="table-container" v-else>
  20. <!-- 查询框 -->
  21. <view class="container">
  22. <view class="search-container">
  23. <uni-easyinput prefixIcon="search" v-model="stockLocNum" placeholder="请输入仓位"
  24. style="margin-right: 5px;">
  25. </uni-easyinput>
  26. <button class="search-button" @click="search">查询</button>
  27. </view>
  28. <!-- <view style="padding:0 5px 2px 5px;">
  29. <uni-datetime-picker v-model="range" type="daterange" @maskClick="maskClick" />
  30. </view> -->
  31. </view>
  32. <!-- 表格容器 -->
  33. <scroll-view class="table-scroll" scroll-y @scroll="onScroll">
  34. <!-- 表头 -->
  35. <view class="table-header" ref="tableHeader">
  36. <view class="table-cell1">仓位编号</view>
  37. </view>
  38. <!-- 表格内容 -->
  39. <view class="table-body">
  40. <view class="table-row" v-for="(item, index) in stockList" :key="item.FStockLocNum">
  41. <view class="checkbox-container">
  42. <checkbox :value="item.FStockLocNum" :checked="item.checked"
  43. @tap="handleCheckboxClick(item.FStockLocNum)" />
  44. <view style="display: flex; justify-content: center; align-items: center;">
  45. {{ item.FStockLocNum}}({{item.FQty}})
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </scroll-view>
  51. <!-- 底部按钮 -->
  52. <view class="bottom-bar">
  53. <button class="mini-btn button" type="primary" size="default" @click="stockSubmit">确定</button>
  54. <button class="mini-btn button" type="warn" size="default" @click="goBack">取消</button>
  55. </view>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. import {
  61. getInfoByBarcode,
  62. getStockInfo,
  63. Querylocation
  64. } from '../../api/production_replenishment';
  65. import modal from '../../plugins/modal';
  66. import {
  67. playVoice,
  68. audioUrls
  69. } from '@/utils/audio.js'
  70. // import modal from '../../uni_modules/uview-ui/libs/config/props/modal';
  71. export default {
  72. onLoad(option) {
  73. this.formId = uni.getStorageSync("formId")
  74. const isCreate = JSON.parse(decodeURIComponent(option.isCreate))
  75. const item = JSON.parse(decodeURIComponent(option.item))
  76. const index = JSON.parse(decodeURIComponent(option.index))
  77. console.log(item)
  78. console.log(index)
  79. this.isCreate = isCreate
  80. this.item = item
  81. this.index = index
  82. },
  83. data() {
  84. return {
  85. isCreate: false,
  86. stockList: [],
  87. selectedItemId: '',
  88. stockLocNum: '',
  89. formId: '',
  90. item: {},
  91. index: '',
  92. isReplace: false,
  93. rules: {
  94. FQty: {
  95. rules: [{
  96. required: true,
  97. errorMessage: '请输入调拨数量',
  98. },
  99. ]
  100. },
  101. },
  102. };
  103. },
  104. computed: {
  105. },
  106. methods: {
  107. handleError(error) {
  108. playVoice(audioUrls.failVoiceUrl)
  109. console.error('操作失败:', error);
  110. modal.confirm(error).then(res => {
  111. if (res) {} else {}
  112. })
  113. },
  114. submit() {
  115. console.log(this.item)
  116. this.$refs.form.validate().then(res => {
  117. this.item["index"] = this.index
  118. let self = this
  119. uni.navigateBack({
  120. success: function() {
  121. // 传递数据给上一页
  122. uni.$emit('item', self.item);
  123. }
  124. });
  125. }).catch(err => {
  126. console.log(err);
  127. })
  128. },
  129. async stockSubmit() {
  130. if (this.selectedItemId == null) {
  131. modal.msgError("请选择仓位")
  132. playVoice(audioUrls.failVoiceUrl)
  133. return
  134. }
  135. this.item['FDestStockId.FNumber'] = this.item["FStockId.FNumber"]
  136. this.item['FDestStockLocId.FF102029.FNumber'] = this.selectedItemId
  137. let self = this
  138. console.log(self.item)
  139. uni.navigateBack({
  140. success: () => {
  141. uni.$emit('selectStock', self.item);
  142. }
  143. });
  144. },
  145. goBack() {
  146. uni.navigateBack();
  147. },
  148. search() {
  149. modal.loading('获取数据中,请耐心等待...')
  150. let data = {
  151. usertoken: "99302b4923aa42298c5922b7b68bcff9",
  152. stockNum: this.item["FStockId.FNumber"],
  153. stockLocNum: this.stockLocNum
  154. }
  155. Querylocation(data).then(res => {
  156. console.log(res);
  157. this.handleResponse(res)
  158. })
  159. },
  160. onScroll(e) {
  161. const scrollLeft = e.detail.scrollLeft;
  162. this.headerLeft = -scrollLeft; // 更新表头左侧位置,实现横向滚动时的对齐效果
  163. },
  164. checkboxChange: function(e) {
  165. console.log(e)
  166. var items = this.BillList,
  167. values = e.detail.value;
  168. console.log(values)
  169. this.selected = values
  170. console.log(this.selected)
  171. for (var i = 0, lenI = items.length; i < lenI; ++i) {
  172. const item = items[i]
  173. if (values.includes(item.FID)) {
  174. this.$set(item, 'checked', true)
  175. } else {
  176. this.$set(item, 'checked', false)
  177. }
  178. }
  179. console.log(items)
  180. },
  181. handleResponse(res) {
  182. // 关闭加载提示
  183. modal.closeLoading();
  184. // 检查响应是否为空
  185. if (res.length === 0) {
  186. modal.msg("请确认输入条件有效!");
  187. playVoice(audioUrls.failVoiceUrl);
  188. return;
  189. }
  190. // 处理数据去重并更新状态
  191. this.updateStockList(res);
  192. },
  193. updateStockList(data) {
  194. this.stockList = data.results;
  195. console.log(this.stockList)
  196. },
  197. handleCheckboxClick(itemId) {
  198. console.log(itemId)
  199. // 取消之前选中的项
  200. if (this.selectedItemId === itemId) {
  201. this.selectedItemId = null;
  202. this.stockList.forEach(item => {
  203. item.checked = false;
  204. });
  205. console.log(this.stockList)
  206. } else {
  207. // 更新选中项
  208. this.selectedItemId = itemId;
  209. this.stockList.forEach(item => {
  210. item.checked = (item.FStockLocNum === itemId);
  211. });
  212. console.log(this.stockList)
  213. }
  214. console.log(this.selectedItemId)
  215. this.$forceUpdate()
  216. },
  217. }
  218. };
  219. </script>
  220. <style>
  221. /deep/ .is-disabled {
  222. background-color: #ffffff !important;
  223. color: #0d0d0d !important;
  224. }
  225. .example {
  226. padding-left: 10px;
  227. padding-right: 10px;
  228. background-color: #fff;
  229. }
  230. .segmented-control {
  231. margin-bottom: 15px;
  232. }
  233. .button-group {
  234. margin-top: 15px;
  235. display: flex;
  236. justify-content: space-around;
  237. }
  238. .form-item {
  239. display: flex;
  240. align-items: center;
  241. }
  242. .button {
  243. display: flex;
  244. align-items: center;
  245. height: 35px;
  246. margin-left: 10px;
  247. }
  248. .table-container {
  249. width: 100%;
  250. height: 100%;
  251. display: flex;
  252. flex-direction: column;
  253. }
  254. .search-container {
  255. display: flex;
  256. /* justify-content: flex-start; */
  257. flex-direction: row;
  258. align-items: center;
  259. padding: 5px;
  260. /* border-bottom: 1px solid #ccc; */
  261. flex-wrap: wrap;
  262. }
  263. .search-button {
  264. /* padding: 8px 16px; */
  265. border: none;
  266. border-radius: 4px;
  267. background-color: #007bff;
  268. color: #fff;
  269. cursor: pointer;
  270. }
  271. .table-scroll {
  272. /* position: absolute; */
  273. flex: 1;
  274. overflow-x: auto;
  275. overflow-y: hidden;
  276. }
  277. .table-header {
  278. position: sticky;
  279. top: 0;
  280. background-color: #f0f0f0;
  281. font-weight: bold;
  282. border-bottom: 1px solid #ccc;
  283. display: flex;
  284. z-index: 1;
  285. /* 确保表头在内容之上 */
  286. }
  287. .table-cell1 {
  288. width: 100%;
  289. padding: 10px;
  290. text-align: center;
  291. border-right: 1px solid #ccc;
  292. }
  293. .table-cell1-1 {
  294. min-width: 150px;
  295. padding: 10px;
  296. text-align: left;
  297. border-right: 1px solid #ccc;
  298. }
  299. .table-cell {
  300. min-width: 100px;
  301. padding: 10px;
  302. text-align: center;
  303. border-right: 1px solid #ccc;
  304. }
  305. .header-cell {
  306. border-right: none;
  307. /* 取消最后一列的右边框 */
  308. }
  309. .table-body {
  310. flex: 1;
  311. /* width: fit-content; */
  312. /* 使内容宽度适应内容的宽度 */
  313. }
  314. .table-row {
  315. width: 100%;
  316. /* display: flex; */
  317. border-bottom: 1px solid #ccc;
  318. }
  319. .checkbox {
  320. width: 100%;
  321. height: 100%;
  322. display: flex;
  323. justify-content: center;
  324. align-items: center;
  325. }
  326. .bottom-bar {
  327. display: flex;
  328. /* justify-content: center; */
  329. justify-content: flex-end;
  330. /* 将按钮靠右对齐 */
  331. align-items: center;
  332. /* padding: 10px; */
  333. padding: 3px;
  334. background-color: #f0f0f0;
  335. position: fixed;
  336. bottom: 0;
  337. left: 0;
  338. width: 100%;
  339. box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1); /* 可选:添加阴影效果 */
  340. z-index: 1000; /* 确保按钮组在其他内容之上 */
  341. }
  342. .button {
  343. margin: 0 10px;
  344. /* padding: 10px 20px; */
  345. }
  346. .checkbox-container {
  347. width: 100%;
  348. padding: 10px;
  349. /* text-align: center; */
  350. border-right: 1px solid #ccc;
  351. display: flex;
  352. align-items: center;
  353. /* margin-left: 10px;
  354. margin-right: 10px; */
  355. /* 可根据需要调整间距 */
  356. }
  357. </style>